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