afe.apis.transform
Tensor transformations that can be applied to a model’s input or output.
Classes
A transformation on a tensor. |
Functions
|
The argmax operation applied over a single axis of a tensor. |
|
The reshape_transform operation |
|
The layout_transform operation. |
|
The tessellation_transform operation. |
|
The detessellation_transform operation. |
|
The pack_transform operation. |
|
The unpack_transform operation. |
|
The normalization_transform operation. |
|
The quantization_transform operation. |
|
The dequantization_transform operation. |
|
The resize_transform operation. |
|
The chroma_upsample_transform operation. |
|
The yuv_rgb_conversion_transform operation. |
|
The bgr_rgb_conversion_transform operation. |
|
The crop_transform operation. |
|
The slice_transform operation. |
|
The sigmoid_transform operation. |
|
The nms_maxpool_transform operation. |
|
The softmax transform operation. |
|
Make a transform that is the composition of the given transforms. |
|
An identity transformation on a tensor. |
Module Contents
- class afe.apis.transform.Transform[source]
A transformation on a tensor.
- abstract apply(t: afe.apis.compilation_job_base.Tensor) afe.apis.compilation_job_base.Tensor [source]
Apply this transform to a tensor. Raise an exception if the tensor’s type is not suitable for this transform.
- abstract get_result_type(parameter_type: afe.ir.tensor_type.TensorType) afe.ir.tensor_type.TensorType [source]
Get the type of this transform’s output when it is applied to input of the given type. Raise an exception if the transform cannot be applied to a tensor having the given type.
- abstract extract_ir(input_type: afe.ir.tensor_type.TensorType, input_name: afe.ir.defines.NodeName, output_base_name: afe.ir.defines.NodeName) tuple[afe.ir.tensor_type.TensorType, list[afe.ir.node.AwesomeNode]] [source]
Extract the internal representation of this transform.
- afe.apis.transform.argmax(*, axis: int) Transform [source]
The argmax operation applied over a single axis of a tensor.
- Parameters:
axis – Axis to reduce
- Returns:
The argmax transformation
- afe.apis.transform.reshape_transform(*, newshape: list[int]) Transform [source]
The reshape_transform operation
- Parameters:
newshape – New shape after reshape transform
- Returns:
The reshape transformation
- afe.apis.transform.layout_transform(*, src_layout: str, dst_layout: str) Transform [source]
The layout_transform operation.
- Parameters:
src_layout – Layout of the input tensor
dst_layout – Layout of the output tensor
- Returns:
The layout_transform transformation
- afe.apis.transform.tessellation_transform(*, slice_shape: Sequence[int], align_c16: bool, cblock: bool) Transform [source]
The tessellation_transform operation.
- Parameters:
slice_shape – Shape of slice to tessellate.
align_c16 – True to align channels to 16 in a tessellated slice
cblock – True to interleave the channel blocks in a tessellated slice.
- Returns:
The tessellation_transform transformation
- afe.apis.transform.detessellation_transform(*, slice_shape: Sequence[int], align_c16: bool, cblock: bool, frame_type: afe.ir.tensor_type.TensorType) Transform [source]
The detessellation_transform operation.
- Parameters:
slice_shape – Shape of slice to detessellate
align_c16 – True to indicate that slice channels are aligned to 16.
cblock – True to indicate that channel blocks are interleaved in a slice.
frame_type – Tensor type of de-tessellated frame
- Returns:
The detessellation_transform transformation
- afe.apis.transform.pack_transform() _PackTransform [source]
The pack_transform operation.
- Returns:
The pack_transform transformation
- afe.apis.transform.unpack_transform(*, tensor_types: list[afe.ir.tensor_type.TensorType]) _UnpackTransform [source]
The unpack_transform operation.
- Parameters:
tensor_types – List of target tensor types after unpack
- Returns:
The unpack_transform transformation
- afe.apis.transform.normalization_transform(*, channel_params: list[tuple[float, float, float]]) Transform [source]
The normalization_transform operation.
- Parameters:
channel_params – The list of tuples for (divisor, mean, standard deviation)
- Returns:
The normalization_transform transformation
- afe.apis.transform.quantization_transform(*, channel_params: list[tuple[float, int]], num_bits: int, rounding: ml_kernels.math_helpers.RoundType = _RoundType.TONEAREST) Transform [source]
The quantization_transform operation.
- Parameters:
channel_params – The list of tuples for (quant_scale, zero_point)
num_bits – The number of bits used for quantization
rounding – The rounding type for quantization
- Returns:
The quantization_transform transformation
- afe.apis.transform.dequantization_transform(*, channel_params: list[tuple[float, int]]) Transform [source]
The dequantization_transform operation.
- Parameters:
channel_params – The list of tuples for (quant_scale, zero_point)
- Returns:
The dequantization_transform transformation
- afe.apis.transform.resize_transform(*, target_height: int, target_width: int, keep_aspect: bool, deposit_location: afe.apis.defines.ResizeDepositLocation, method: afe.apis.defines.ResizeMethod) Transform [source]
The resize_transform operation.
- Parameters:
target_height – Target height of resized tensor
target_width – Target width of resized tensor
keep_aspect – Boolean flag to keep aspect ratio
deposit_location – Enum to indicate deposit position of resized image
method – Enum to indicate supported interpolation methods
- Returns:
The resize_transform transformation
- afe.apis.transform.chroma_upsample_transform(*, frame_height: int, frame_width: int, yuv_sampling: afe.apis.defines.ChromaSampling) Transform [source]
The chroma_upsample_transform operation.
- Parameters:
frame_height – Height of full sampling frame
frame_width – Width of full sampling frame
yuv_sampling – Chroma sampling Enum
- Returns:
The chroma_upsample_transform transformation
- afe.apis.transform.yuv_rgb_conversion_transform(*, conversion: afe.apis.defines.ColorConversion, std: afe.apis.defines.ColorSpaceStandard) Transform [source]
The yuv_rgb_conversion_transform operation.
- Parameters:
conversion – Direction of conversion between YUV and RGB
std – Standard for color space conversion
- Returns:
The yuv_rgb_conversion_transform transformation
- afe.apis.transform.bgr_rgb_conversion_transform(*, conversion: afe.apis.defines.ColorConversion) Transform [source]
The bgr_rgb_conversion_transform operation.
- Parameters:
conversion – Direction of conversion between BGR and RGB
- Returns:
The bgr_rgb_conversion_transform transformation
- afe.apis.transform.crop_transform(*, bounding_box: list[tuple[int, int]]) Transform [source]
The crop_transform operation.
- Parameters:
bounding_box – Rectangle area to crop, as a list of 2 items. bounding_box[0] is the (x,y) position of the cropped area’s origin within the input area. bounding_box[1] is the (x,y) past-the-end position of the cropped area within the input area.
- Returns:
The crop_transform transformation
- afe.apis.transform.slice_transform(*, begin: list[int], end: list[int]) Transform [source]
The slice_transform operation.
- Parameters:
begin – Begin indices for each dimension.
end – End indices for each dimension.
- Returns:
The slice_transform transformation
- afe.apis.transform.sigmoid_transform(*, save_int16: bool) Transform [source]
The sigmoid_transform operation.
- Parameters:
save_int16 – Boolean flag to save output as 16-bit fixed point
- Returns:
The sigmoid_transform transformation
- afe.apis.transform.nms_maxpool_transform(*, kernel: int) Transform [source]
The nms_maxpool_transform operation.
- Parameters:
kernel – Size of pooling kernel
- Returns:
The nms_maxpool_transform transformation
- afe.apis.transform.softmax_transform(*, axis: int) Transform [source]
The softmax transform operation.
- Parameters:
axis – Axis to sum over
- Returns:
The softmax transform
- afe.apis.transform.compose(transforms: list[Transform]) Transform [source]
Make a transform that is the composition of the given transforms.
The composition performs transforms in the same order as they occur in the list:
compose([x, y]).apply(t) == y.apply(x.apply(t))
- Parameters:
transforms – Transforms to compose
- Returns:
Their composition