afe.backends.checker_utils
This file contains utility functions that are used in deciding if an IR can be supported or not supported in certain backends
Attributes
Functions
|
Find and return the first matching attribute dictionary in the list. |
|
|
Return True if the average pooling operator includes all padding |
|
Return True if the exclude attribute exists and is True. |
|
Return True if reduce axes do not contain batch and channel axis, |
|
Return True is the keepdims attribute exists and is True |
|
Note: If exclude is True, reduction will be performed on the axes that are NOT in axis instead. |
|
Return True if all input tensors' 0 axis (batch dimension) shape is 1 |
|
Return True if all dilations are 1 |
|
Checks if scaling values for h_axis and w_axis are supported for the resize method. If not |
|
Check if pytorch_half_pixel coordinate transformation mode is same as half_pixel. |
|
|
Return True if align_corners is False |
Return True if ceil_mode is False |
|
|
|
Reject if padding is given for the wrong number of dimensions. |
|
|
Accept if the reduce operator performs reduction over axis 3 (the channel axis). |
|
Return True if the first attribute's axis is 3. This should be used |
|
Return True if the first attribute's axis is 3 or -1. This should be used |
Return True if the output_size attribute is not None and output_size along |
|
Return True if the padding's pad_mode is 'constant' and the pad_width along all |
|
Does not support when coordinate_transformation_mode in image.resize is 'tf_crop_and_resize' |
|
Return True if the axis of tuple_concat is not 0 (not batch dimension) |
|
Return True if dilations of 2d/3d transpose convolution are all equal to 1 |
|
Return True if the groups attribute is 1 |
|
MLA HW only support stride in the given range: [1, 2, 4, 8, 16] for transposed convolution. |
|
|
MLA HW only support stride as 1 or 2 for depthwise transposed convolution. |
Special case for depthwise conv2d_transpose. |
|
Return True if strided slice strides are all equal to 1 |
|
|
Return True if all inputs are 4D tensors. |
|
Return True if all inputs are either 4D or 5D tensors. |
Return True if all output types specified in the "output_types" attribute are float32. |
|
|
Return True if all output types specified in the "output_types" attribute are int8. |
Return True if all output types specified in the "output_types" attribute are int32. |
|
Return True if slice begin or end on channel axis is multiple of 16. |
|
|
Returns True if both inputs are 4D with the same shape or exactly one input is a scalar |
Returns True if both inputs are broadcastable. |
|
Accept if einsum equation is representing a batch matmul operation. |
|
Accept if the value of strides is in range [1, 31]. |
|
Accept if broadcast shapes are broadcastable. |
|
Accept if transpose is not affecting the batch_axis (axes[0] == 0). |
|
|
Accept if axis is all spatial dimensions. |
|
Accept if interpolation is 2D |
Module Contents
- afe.backends.checker_utils.find_matching_attr(match: Callable[[attrdict.AttrDict], bool], attrs: List[attrdict.AttrDict], *, description: str | None = None) attrdict.AttrDict [source]
Find and return the first matching attribute dictionary in the list. Raise a ValueError if there is no matching dictionary.
- Parameters:
match – Function that checks whether an attribute dictionary matches.
attrs – Attributes to search
description – Description of what it attempts to match. Used when raising an error.
- Returns:
First matching attribute in the list
- afe.backends.checker_utils.unsupported_op_code_to_message(code: int | List[int]) str | List[str] [source]
- afe.backends.checker_utils.padding_is_present_and_included(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the average pooling operator includes all padding values in the averaging operation. This includes the situation when there is no padding.
- afe.backends.checker_utils.exclude_of_reduce_expression_is_true(args: afe.backends.ExprCheckInfo) bool [source]
Return True if the exclude attribute exists and is True.
- afe.backends.checker_utils.supported_mean_operator_axes_and_input_size(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
- Return True if reduce axes do not contain batch and channel axis,
and input size on a reduce axis is less than 128.
- afe.backends.checker_utils.keepdims_of_reduce_expression_is_true(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True is the keepdims attribute exists and is True
- afe.backends.checker_utils.axes_of_reduce_expression_are_nonzero(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Note: If exclude is True, reduction will be performed on the axes that are NOT in axis instead. So if exclude is true we want axes to include zero instead. Note: If axes is None the operation is performed across all axes and thus we return false since we reduce along the 0th axis
- afe.backends.checker_utils.zero_axis_of_input_has_shape_of_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all input tensors’ 0 axis (batch dimension) shape is 1 or all inputs are scalar.
- afe.backends.checker_utils.dilations_of_pooling_expression_are_greater_than_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all dilations are 1
- afe.backends.checker_utils.check_resize_is_supported(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Checks if scaling values for h_axis and w_axis are supported for the resize method. If not returns False. The following are supported. 1. Only positive scaling factors are supported. 2. If method is ‘linear’ or ‘bilinear’, any scaling factor is supported. However, for 8-bit integers any scaling
more than 63 may lead to loss in accuracy.
If the method is ‘nearest neighbor’ a power of two scaling factor is supported.
Any other method or scaling factor is not supported.
- afe.backends.checker_utils.pytorch_half_pixel_is_half_pixel(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Check if pytorch_half_pixel coordinate transformation mode is same as half_pixel. It will be same if the size of the resized tensor is greater than 1.
- afe.backends.checker_utils.corners_not_aligned(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if align_corners is False
- afe.backends.checker_utils.pooling_expression_ceil_mode_is_false(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if ceil_mode is False
- afe.backends.checker_utils.supported_pool_size(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
- afe.backends.checker_utils.pool_explicit_padding_incorrect_dimension(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Reject if padding is given for the wrong number of dimensions.
- afe.backends.checker_utils.axis_is_none_or_contains_0(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
- afe.backends.checker_utils.reduce_axis_is_3(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Accept if the reduce operator performs reduction over axis 3 (the channel axis). The reduction axis is determined from the input shape and the attributes ‘axis’ and ‘exclude’.
- afe.backends.checker_utils.prelu_axis_is_3(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the first attribute’s axis is 3. This should be used for checking the composite prelu_const operator. It checks that the PRelu’s alpha axis is the channel axis, as required by the MLA.
- afe.backends.checker_utils.softmax_axis_is_3(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the first attribute’s axis is 3 or -1. This should be used for checking the composite softmax_const operator. It checks that the Softmax axis is the channel axis, as required by the MLA.
- afe.backends.checker_utils.output_size_shape_is_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the output_size attribute is not None and output_size along all dimension are 1
- afe.backends.checker_utils.pad_mode_is_constant_and_pad_width_is_0(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the padding’s pad_mode is ‘constant’ and the pad_width along all dimensions are 0
- afe.backends.checker_utils.check_transformation_mode_is_other_than_tf_crop_resize(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Does not support when coordinate_transformation_mode in image.resize is ‘tf_crop_and_resize’
- afe.backends.checker_utils.tuple_concat_axis_is_not_0(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the axis of tuple_concat is not 0 (not batch dimension)
- afe.backends.checker_utils.axes_are_nonzero_or_zero_axis_of_input_has_shape_of_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
- afe.backends.checker_utils.dilations_of_conv_transpose_expression_are_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if dilations of 2d/3d transpose convolution are all equal to 1
- afe.backends.checker_utils.depthwise_or_number_of_groups_is_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
- afe.backends.checker_utils.number_of_groups_is_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if the groups attribute is 1
- afe.backends.checker_utils.stride_is_power_of_2_upto_16(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
MLA HW only support stride in the given range: [1, 2, 4, 8, 16] for transposed convolution. Return True if stride value is in that range.
- afe.backends.checker_utils.stride_is_1_or_2(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
MLA HW only support stride as 1 or 2 for depthwise transposed convolution. Return True if stride value is 1 or 2.
- afe.backends.checker_utils.number_of_groups_equals_number_of_input_channels(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Special case for depthwise conv2d_transpose.
Return True if the total groups number in a decomposed conv2d_transpose is same as input channel number. This means the operator is a depthwise operator
- afe.backends.checker_utils.strided_slice_stride_is_1(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if strided slice strides are all equal to 1
- afe.backends.checker_utils.input_is_4d(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all inputs are 4D tensors.
- afe.backends.checker_utils.input_is_4d_or_5d(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all inputs are either 4D or 5D tensors.
- afe.backends.checker_utils.all_tensors_are_float32(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all output types specified in the “output_types” attribute are float32.
- afe.backends.checker_utils.all_tensors_are_int8(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all output types specified in the “output_types” attribute are int8.
- afe.backends.checker_utils.all_tensors_are_int32(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if all output types specified in the “output_types” attribute are int32.
- afe.backends.checker_utils.strided_slice_on_chanel_axis_is_mul_of_16(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Return True if slice begin or end on channel axis is multiple of 16. End of last part must not be multiple of 16.
- afe.backends.checker_utils.binary_operator_have_same_input_shapes_or_one_scalar_input(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Returns True if both inputs are 4D with the same shape or exactly one input is a scalar
- afe.backends.checker_utils.binary_operator_inputs_are_broadcastable(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Returns True if both inputs are broadcastable.
- afe.backends.checker_utils.check_number_of_einsum_inputs(num_inputs: int) Callable[[afe.backends.ExprCheckInfo], afe.backends.backend_checker.Decision] [source]
- afe.backends.checker_utils.einsum_equation_is_supported(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Accept if einsum equation is representing a batch matmul operation.
- afe.backends.checker_utils.check_strides_in_conv(args: afe.backends.ExprCheckInfo) afe.backends.backend_checker.Decision [source]
Accept if the value of strides is in range [1, 31].
- afe.backends.checker_utils.broadcast_to_output_is_4d_and_broadcastable(args: afe.backends.ExprCheckInfo)[source]
Accept if broadcast shapes are broadcastable.
- afe.backends.checker_utils.check_transpose_affecting_batch_axis(args: afe.backends.ExprCheckInfo)[source]
Accept if transpose is not affecting the batch_axis (axes[0] == 0).
- afe.backends.checker_utils.supported_variance_axis(args: afe.backends.ExprCheckInfo)[source]
Accept if axis is all spatial dimensions.
- afe.backends.checker_utils.supported_gridsample(args: afe.backends.ExprCheckInfo) bool [source]
- Accept if interpolation is 2D
and mode is ‘linear’ and padding_mode is not ‘reflection’.