mlir.dialects._tosa_ops_gen

Attributes

Classes

_Dialect

AbsOp

Elementwise absolute value operation.

AddOp

Elementwise addition of input1 and input2. Axis of size 1 will be broadcast,

ApplyScaleOp

Applies rescaling for fixed point values. This behavior is replicated in

ArgMaxOp

This returns the index with the largest value across the given axis of the

ArithmeticRightShiftOp

Elementwise arithmetic right shift of input1 by the amount specified in

AvgPool2dOp

This performs an average pooling over the given input tensor. A sliding

BitwiseAndOp

Elementwise bitwise AND of input1 and input2. Axis of size 1

BitwiseNotOp

Elementwise bitwise NOT of input tensor.

BitwiseOrOp

Elementwise bitwise OR of input1 and input2. Axis of size 1 will be

BitwiseXorOp

Elementwise bitwise XOR of input1 and input2. Axis of size 1 will be

CastFromBlockScaledOp

Apply the scales from a scale tensor to the values in a value tensor, casting

CastOp

Casts a tensor from one data type to another.

CastToBlockScaledOp

Calculate a scale value per block of input values and use that to calculate

CeilOp

Elementwise ceiling operation.

ClampOp

Clamp to an arbitrary minimum and maximum value.

ClzOp

Elementwise count leading zeros operation.

ConcatOp

Concatenate a list of tensors along a given axis.

ConstOp

A node containing constant data for use as the input to an operation. May

ConstShapeOp

A node containing a constant shape.

Conv2DOp

Performs a 2D convolution over the given tensor input, using the weight

Conv3DOp

Performs a 3D convolution over the given input tensor. Implementations

CosOp

Elementwise cosine operation for values given in radians.

CustomOp

Hardware implementing TOSA may choose to add additional custom operators

DepthwiseConv2DOp

Performs 2D convolutions separately over each channel of the given tensor

EqualOp

Elementwise comparison operation.

ErfOp

Gauss error function: $ erf(x) = frac{2}{sqrt{pi}} int_{0}^{x} e^{-t^2} dt $

ExpOp

Elementwise e to the x operation

FFT2dOp

Performs a batched complex 2D Fast Fourier Transform over the input. The

FloorOp

Elementwise floor operation.

GatherOp

Generate a tensor for which each element in the output is a subtensor of the

GreaterEqualOp

Elementwise comparison operation.

GreaterOp

Elementwise greater than comparison operation.

IdentityOp

Returns a tensor with the same shape, type, and contents as the input.

IfOp

Evaluates a Boolean condition and then takes one of two distinct execution

IntDivOp

Elementwise integer divide of input1 by input2. Axis of size 1 will be

LogOp

Elementwise natural logarithm operation

LogicalAndOp

Elementwise logical AND of input1 and input2. Axis of size 1 will be

LogicalLeftShiftOp

Elementwise logical left-shift of input1 by the amount specified in input2.

LogicalNotOp

Elementwise logical NOT of input.

LogicalOrOp

Elementwise logical OR of input1 and input2. Axis of size 1 will be

LogicalRightShiftOp

Elementwise logical right shift of input1 by the amount specified in input2.

LogicalXorOp

Elementwise logical XOR of input1 and input2. Axis of size 1 will be

MatMulOp

Performs two dimensional matrix multiplications.

MatmulTBlockScaledOp

Performs two dimensional matrix multiplications using block scaled tensors. The block

MaxPool2dOp

This performs a max pooling over the given input tensor. A sliding window of

MaximumOp

Elementwise max of input1 and input2. Axis of size 1 will be broadcast, as

MinimumOp

Elementwise minimum of input1 and input2. Axis of size 1

MulOp

Elementwise multiplication (Hadamard product) of input1 and input2.

NegateOp

Elementwise negation operation.

PadOp

Pads a tensor along the borders of each dimension with a supplied value.

PowOp

Elementwise input1 value raised to the power of input2.

RFFT2dOp

Performs a batched 2D real-valued Fast Fourier Transform over the input where

ReciprocalOp

Elementwise reciprocal operation. For integer operation, a TABLE should be

ReduceAllOp

Reduce a tensor along the given axis with a logical AND operation.

ReduceAnyOp

Reduce a tensor along the given axis with a logical OR operation.

ReduceMaxOp

Reduce a tensor along the given axis with a maximum operation.

ReduceMinOp

Reduce a tensor along the given axis with a minimum operation.

ReduceProductOp

Reduce a tensor along the given axis by computing the product of the axis.

ReduceSumOp

Reduce a tensor along the given axis by computing the sum of the axis.

RescaleOp

RESCALE is defined using an integer multiply, add, and shift.

ReshapeOp

Returns a tensor with the same type/values as the input, with a new shape

ResizeOp

Resizes a tensor. Resize is only allowed in the H and W dimensions.

ReverseOp

Returns a tensor with the same type/values as the input, with the data

RsqrtOp

Elementwise reciprocal square root operation. For integer operation, a TABLE

ScatterOp

The values_out tensor is set to the values_in tensor with data modified as

SelectOp

Elementwise select of the output based on a condition.

SigmoidOp

Applies the sigmoid logistic function to each element of the input tensor:

SinOp

Elementwise sine operation for values given in radians.

SliceOp

Extracts a slice of input1, beginning at the start coordinates,

SubOp

Elementwise subtraction of input1 and input2. Axis of size 1 will be

TableOp

Table lookup operation. For int8_t TABLE operation, perform a 256 entry

TanhOp

Parameterized hyperbolic tangent: $ tanh(x) = frac{1 - e^{-2x}}{1 + e^{-2x}} $.

TileOp

Replicates input1 multiples times along each dimension.

TransposeConv2DOp

Performs a 2D transposed convolution over the given tensor input, using the

TransposeOp

Permutes the dimensions of the input tensor input1 based on the perms

VariableOp

Defines a new TOSA variable. This is a persistent mutable value across multiple

VariableReadOp

Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.

VariableWriteOp

Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.

WhileOp

Generates and evaluates a Boolean condition and either executes a loop body

YieldOp

return operation within the conditional and body of

Functions

abs(→ _ods_ir)

add(→ _ods_ir)

apply_scale(→ _ods_ir)

argmax(→ _ods_ir)

arithmetic_right_shift(→ _ods_ir)

avg_pool2d(→ _ods_ir)

bitwise_and(→ _ods_ir)

bitwise_not(→ _ods_ir)

bitwise_or(→ _ods_ir)

bitwise_xor(→ _ods_ir)

cast_from_block_scaled(→ _ods_ir)

cast(→ _ods_ir)

cast_to_block_scaled(→ _ods_ir)

ceil(→ _ods_ir)

clamp(→ _ods_ir)

clz(→ _ods_ir)

concat(→ _ods_ir)

const(→ _ods_ir)

const_shape(→ _ods_ir)

conv2d(→ _ods_ir)

conv3d(→ _ods_ir)

cos(→ _ods_ir)

custom(→ Union[_ods_ir, _ods_ir, CustomOp])

depthwise_conv2d(→ _ods_ir)

equal(→ _ods_ir)

erf(→ _ods_ir)

exp(→ _ods_ir)

fft2d(→ _ods_ir)

floor(→ _ods_ir)

gather(→ _ods_ir)

greater_equal(→ _ods_ir)

greater(→ _ods_ir)

identity(→ _ods_ir)

cond_if(→ Union[_ods_ir, _ods_ir, IfOp])

intdiv(→ _ods_ir)

log(→ _ods_ir)

logical_and(→ _ods_ir)

logical_left_shift(→ _ods_ir)

logical_not(→ _ods_ir)

logical_or(→ _ods_ir)

logical_right_shift(→ _ods_ir)

logical_xor(→ _ods_ir)

matmul(→ _ods_ir)

matmul_t_block_scaled(→ _ods_ir)

max_pool2d(→ _ods_ir)

maximum(→ _ods_ir)

minimum(→ _ods_ir)

mul(→ _ods_ir)

negate(→ _ods_ir)

pad(→ _ods_ir)

pow(→ _ods_ir)

rfft2d(→ _ods_ir)

reciprocal(→ _ods_ir)

reduce_all(→ _ods_ir)

reduce_any(→ _ods_ir)

reduce_max(→ _ods_ir)

reduce_min(→ _ods_ir)

reduce_product(→ _ods_ir)

reduce_sum(→ _ods_ir)

rescale(→ _ods_ir)

reshape(→ _ods_ir)

resize(→ _ods_ir)

reverse(→ _ods_ir)

rsqrt(→ _ods_ir)

scatter(→ _ods_ir)

select(→ _ods_ir)

sigmoid(→ _ods_ir)

sin(→ _ods_ir)

slice(→ _ods_ir)

sub(→ _ods_ir)

table(→ _ods_ir)

tanh(→ _ods_ir)

tile(→ _ods_ir)

transpose_conv2d(→ _ods_ir)

transpose(→ _ods_ir)

variable(→ VariableOp)

variable_read(→ _ods_ir)

variable_write(→ VariableWriteOp)

while_loop(→ Union[_ods_ir, _ods_ir, WhileOp])

yield_(→ YieldOp)

Module Contents

mlir.dialects._tosa_ops_gen._ods_ir
class mlir.dialects._tosa_ops_gen._Dialect(descriptor: object)

Bases: _ods_ir

DIALECT_NAMESPACE = 'tosa'
class mlir.dialects._tosa_ops_gen.AbsOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise absolute value operation.

Example:

%output = tosa.abs(%input1) : (tensor<21x3xf32>) -> tensor<21x3xf32>
OPERATION_NAME = 'tosa.abs'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.abs(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.AddOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise addition of input1 and input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

Example:

// Elementwise addition.
%out = tosa.add %input1, %input2 : tensor<12x6xf32>, tensor<12x6xf32> -> tensor<12x6xf32>

// Elementwise addition with broadcasting.
%out = tosa.add %input1, %input2 : tensor<12x6xsi32>, tensor<1x1xsi32> -> tensor<12x6xsi32>
OPERATION_NAME = 'tosa.add'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.add(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ApplyScaleOp(output, value, multiplier, shift, rounding_mode, *, loc=None, ip=None)

Bases: _ods_ir

Applies rescaling for fixed point values. This behavior is replicated in multiple quantized operations (mul, convolution, rescale, matmul, pooling).

The commonplace implementation is to use i64 operations to avoid integer overflow with target specific implementations can use native operations to avoid wider than necessary types.

OPERATION_NAME = 'tosa.apply_scale'
_ODS_REGIONS = (0, True)
value() _ods_ir
multiplier() _ods_ir
shift() _ods_ir
rounding_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.apply_scale(output, value, multiplier, shift, rounding_mode, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ArgMaxOp(output, input, axis, *, nan_mode=None, loc=None, ip=None)

Bases: _ods_ir

This returns the index with the largest value across the given axis of the input tensor. If multiple locations have equal values, returns the first match along the search axis.

OPERATION_NAME = 'tosa.argmax'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.argmax(output, input, axis, *, nan_mode=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ArithmeticRightShiftOp(output, input1, input2, round, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise arithmetic right shift of input1 by the amount specified in input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.arithmetic_right_shift'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
round() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.arithmetic_right_shift(output, input1, input2, round, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.AvgPool2dOp(output, input, input_zp, output_zp, kernel, stride, pad, acc_type, *, loc=None, ip=None)

Bases: _ods_ir

This performs an average pooling over the given input tensor. A sliding window of size given by is passed over the input tensor, with the mean value being placed in the output tensor. When calculating the average, only the number of valid input tensor values, but not padding, are used to calculate the divisor.

OPERATION_NAME = 'tosa.avg_pool2d'
_ODS_REGIONS = (0, True)
input() _ods_ir
input_zp() _ods_ir
output_zp() _ods_ir
kernel() _ods_ir
stride() _ods_ir
pad() _ods_ir
acc_type() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.avg_pool2d(output, input, input_zp, output_zp, kernel, stride, pad, acc_type, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.BitwiseAndOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise bitwise AND of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.bitwise_and'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.bitwise_and(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.BitwiseNotOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise bitwise NOT of input tensor.

OPERATION_NAME = 'tosa.bitwise_not'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.bitwise_not(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.BitwiseOrOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise bitwise OR of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.bitwise_or'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.bitwise_or(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.BitwiseXorOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise bitwise XOR of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.bitwise_xor'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.bitwise_xor(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CastFromBlockScaledOp(output_data, input_data, input_scale, block_size, *, loc=None, ip=None)

Bases: _ods_ir

Apply the scales from a scale tensor to the values in a value tensor, casting the result to the output type. The block dimension must be the last dimension of the tensor.

OPERATION_NAME = 'tosa.cast_from_block_scaled'
_ODS_REGIONS = (0, True)
input_data() _ods_ir
input_scale() _ods_ir
block_size() _ods_ir
output_data() _ods_ir
mlir.dialects._tosa_ops_gen.cast_from_block_scaled(output_data, input_data, input_scale, block_size, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CastOp(output, input, *, loc=None, ip=None)

Bases: _ods_ir

Casts a tensor from one data type to another.

  • This table is showing the supported conversions from the TOSA Specification.

  • The MLIR dialect here can be used to represent other conversions.

Mode | Input | Output |

|--------------------------|———|---------| | fp16 to fp32 | float16 | float32 | | fp16 to int 16 | float16 | int16 | | fp16 to int 32 | float16 | int32 | | fp16 to int 8 | float16 | int8 | | fp32 to fp16 | float32 | float16 | | fp32 to int 16 | float32 | int16 | | fp32 to int 32 | float32 | int32 | | fp32 to int 8 | float32 | int8 | | int 16 to fp16 | int16 | float16 | | int 16 to fp32 | int16 | float32 | | int 32 to fp16 | int32 | float16 | | int 32 to fp32 | int32 | float32 | | int 8 to fp16 | int8 | float16 | | int 8 to fp32 | int8 | float32 | | bool to int 16 | Boolean | int16 | | bool to int 32 | Boolean | int32 | | bool to int 8 | Boolean | int8 | | int 16 to bool | int16 | Boolean | | int 16 to int 32 | int16 | int32 | | int 16 to int 8 | int16 | int8 | | int 32 to bool | int32 | Boolean | | int 32 to int 16 | int32 | int16 | | int 32 to int 8 | int32 | int8 | | int 8 to bool | int8 | Boolean | | int 8 to int 16 | int8 | int16 | | int 8 to int 32 | int8 | int32 | | bf16 to fp32 | bf16 | float32 | | bf16 to int 16 | bf16 | int16 | | bf16 to int 32 | bf16 | int32 | | bf16 to int 8 | bf16 | int8 | | fp32 to bf16 | float32 | bf16 | | int 16 to bf16 | int16 | bf16 | | int 32 to bf16 | int32 | bf16 | | int 8 to bf16 | int8 | bf16 | | bf16 to fp8e4m3 | bf16 | fp8e4m3 | | fp8e4m3 to bf16 | fp8e4m3 | bf16 | | bf16 to fp8e5m2 | bf16 | fp8e5m2 | | fp8e5m2 to bf16 | fp8e5m2 | bf16 | | fp16 to fp8e4m3 | float16 | fp8e4m3 | | fp32 to fp8e4m3 | float32 | fp8e4m3 | | fp8e4m3 to fp16 | fp8e4m3 | float16 | | fp8e4m3 to fp32 | fp8e4m3 | float32 | | fp16 to fp8e5m2 | float16 | fp8e5m2 | | fp32 to fp8e5m2 | float32 | fp8e5m2 | | fp8e5m2 to fp16 | fp8e5m2 | float16 | | fp8e5m2 to fp32 | fp8e5m2 | float32 |

OPERATION_NAME = 'tosa.cast'
_ODS_REGIONS = (0, True)
input() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.cast(output, input, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CastToBlockScaledOp(output_data, output_scale, input_data, block_size, *, loc=None, ip=None)

Bases: _ods_ir

Calculate a scale value per block of input values and use that to calculate scaled data values from an input tensor. The output tensors are cast to the specified scale and value types. The block dimension will be the last dimension of the tensor.

OPERATION_NAME = 'tosa.cast_to_block_scaled'
_ODS_REGIONS = (0, True)
input_data() _ods_ir
block_size() _ods_ir
output_data() _ods_ir
output_scale() _ods_ir
mlir.dialects._tosa_ops_gen.cast_to_block_scaled(output_data, output_scale, input_data, block_size, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CeilOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise ceiling operation.

OPERATION_NAME = 'tosa.ceil'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.ceil(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ClampOp(output, input, min_val, max_val, *, nan_mode=None, loc=None, ip=None)

Bases: _ods_ir

Clamp to an arbitrary minimum and maximum value. Maximum and minimum values are specified as values in the range of the input type. No zero point subtraction is done to the values, thus to clamp to the zero point value, the zero point itself should be supplied as the minimum value.

OPERATION_NAME = 'tosa.clamp'
_ODS_REGIONS = (0, True)
input() _ods_ir
min_val() _ods_ir
max_val() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.clamp(output, input, min_val, max_val, *, nan_mode=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ClzOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise count leading zeros operation.

OPERATION_NAME = 'tosa.clz'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.clz(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ConcatOp(input1, axis, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Concatenate a list of tensors along a given axis. No data conversion happens during a concat operation.

OPERATION_NAME = 'tosa.concat'
_ODS_REGIONS = (0, True)
input1() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.concat(input1, axis, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ConstOp(values, *, results=None, loc=None, ip=None)

Bases: _ods_ir

A node containing constant data for use as the input to an operation. May hold data in any of the supported data formats.

Example:

// Generic form
%out = "tosa.const"() {values = dense<0> : tensor<2x3xi32>} : () -> tensor<2x3xi32>
OPERATION_NAME = 'tosa.const'
_ODS_REGIONS = (0, True)
values() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.const(values, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ConstShapeOp(output, values, *, loc=None, ip=None)

Bases: _ods_ir

A node containing a constant shape.

Example:

// Generic form
%out = "tosa.const_shape"() {values = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
OPERATION_NAME = 'tosa.const_shape'
_ODS_REGIONS = (0, True)
values() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.const_shape(output, values, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.Conv2DOp(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs a 2D convolution over the given tensor input, using the weight tensor. Implementations may choose to skip calculation of multiplies in the padding area.

OPERATION_NAME = 'tosa.conv2d'
_ODS_REGIONS = (0, True)
input() _ods_ir
weight() _ods_ir
bias() _ods_ir
input_zp() _ods_ir
weight_zp() _ods_ir
pad() _ods_ir
stride() _ods_ir
dilation() _ods_ir
acc_type() _ods_ir
local_bound() _ods_ir | None
output() _ods_ir
mlir.dialects._tosa_ops_gen.conv2d(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.Conv3DOp(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs a 3D convolution over the given input tensor. Implementations may choose to skip calculation of multiplies in the padding area.

OPERATION_NAME = 'tosa.conv3d'
_ODS_REGIONS = (0, True)
input() _ods_ir
weight() _ods_ir
bias() _ods_ir
input_zp() _ods_ir
weight_zp() _ods_ir
pad() _ods_ir
stride() _ods_ir
dilation() _ods_ir
acc_type() _ods_ir
local_bound() _ods_ir | None
output() _ods_ir
mlir.dialects._tosa_ops_gen.conv3d(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CosOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise cosine operation for values given in radians.

OPERATION_NAME = 'tosa.cos'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.cos(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.CustomOp(output_list, operator_name, domain_name, implementation_attrs, input_list, *, loc=None, ip=None)

Bases: _ods_ir

Hardware implementing TOSA may choose to add additional custom operators that are not expressed in the existing TOSA operations. These operators are not expected to be portable across TOSA implementations. The input and output signatures must be expressed in the corresponding TOSA node.

operator_name is a string that tells the backend which custom operator is being called.

domain_name is a string identifier which can help avoid name collisions on the identifier field.

implementation_attrs is a string which is a backend and identifier specific set of attributes to the custom operator.

input_list is the set of tensor inputs to the custom operator.

output_list is the list of tensors returned by the operator. The number of operators is backend specific.

Example:

%out = tosa.custom %in {domain_name = "tosa_mlir_test", operator_name =
       "custom_test", implementation_attrs = ""}: (tensor<10xi32>) ->
       (tensor<10xi32>)
OPERATION_NAME = 'tosa.custom'
_ODS_REGIONS = (0, True)
input_list() _ods_ir
operator_name() _ods_ir
domain_name() _ods_ir
implementation_attrs() _ods_ir
output_list() _ods_ir
mlir.dialects._tosa_ops_gen.custom(output_list, operator_name, domain_name, implementation_attrs, input_list, *, loc=None, ip=None) _ods_ir | _ods_ir | CustomOp
class mlir.dialects._tosa_ops_gen.DepthwiseConv2DOp(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs 2D convolutions separately over each channel of the given tensor input, using the weight tensor. Implementations may choose to skip calculation of multiplies in the padding area.

OPERATION_NAME = 'tosa.depthwise_conv2d'
_ODS_REGIONS = (0, True)
input() _ods_ir
weight() _ods_ir
bias() _ods_ir
input_zp() _ods_ir
weight_zp() _ods_ir
pad() _ods_ir
stride() _ods_ir
dilation() _ods_ir
acc_type() _ods_ir
local_bound() _ods_ir | None
output() _ods_ir
mlir.dialects._tosa_ops_gen.depthwise_conv2d(output, input, weight, bias, input_zp, weight_zp, pad, stride, dilation, acc_type, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.EqualOp(input1, input2, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Elementwise comparison operation.

OPERATION_NAME = 'tosa.equal'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.equal(input1, input2, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ErfOp(output, input, *, loc=None, ip=None)

Bases: _ods_ir

Gauss error function: $ erf(x) = frac{2}{sqrt{pi}} int_{0}^{x} e^{-t^2} dt $ For quantized integer data types, the TABLE operator should be used instead with the following definition. The ERF table has 513 entries each of 16-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64.

OPERATION_NAME = 'tosa.erf'
_ODS_REGIONS = (0, True)
input() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.erf(output, input, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ExpOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise e to the x operation

OPERATION_NAME = 'tosa.exp'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.exp(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.FFT2dOp(output_real, output_imag, input_real, input_imag, inverse, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs a batched complex 2D Fast Fourier Transform over the input. The complex input values are constructed from the corresponding values in the input_real and input_imag tensors. The resulting values in the output are split into the output_real and output_imag tensors. No normalization is applied on either the forward or inverse versions of the operation.

Example:

%output_real, %output_imag = tosa.fft2d %input_real, %input_imag : (tensor<8x9xf32>, tensor<8x9xf32>) -> (tensor<8x9xf32>, tensor<8x9xf32>)
OPERATION_NAME = 'tosa.fft2d'
_ODS_REGIONS = (0, True)
input_real() _ods_ir
input_imag() _ods_ir
inverse() _ods_ir
local_bound() _ods_ir | None
output_real() _ods_ir
output_imag() _ods_ir
mlir.dialects._tosa_ops_gen.fft2d(output_real, output_imag, input_real, input_imag, inverse, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.FloorOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise floor operation.

OPERATION_NAME = 'tosa.floor'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.floor(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.GatherOp(output, values, indices, *, loc=None, ip=None)

Bases: _ods_ir

Generate a tensor for which each element in the output is a subtensor of the values tensor based on the indices. N is the number of batches, W the number of indices in each batch, K the range of each index and C the number data channels for each index.

OPERATION_NAME = 'tosa.gather'
_ODS_REGIONS = (0, True)
values() _ods_ir
indices() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.gather(output, values, indices, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.GreaterEqualOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise comparison operation.

OPERATION_NAME = 'tosa.greater_equal'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.greater_equal(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.GreaterOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise greater than comparison operation.

OPERATION_NAME = 'tosa.greater'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.greater(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.IdentityOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Returns a tensor with the same shape, type, and contents as the input.

OPERATION_NAME = 'tosa.identity'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.identity(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.IfOp(output_list, condition, input_list, *, loc=None, ip=None)

Bases: _ods_ir

Evaluates a Boolean condition and then takes one of two distinct execution paths. This implements the semantic If-then-else structure.

OPERATION_NAME = 'tosa.cond_if'
_ODS_REGIONS = (2, True)
condition() _ods_ir
input_list() _ods_ir
output_list() _ods_ir
then_graph() _ods_ir
else_graph() _ods_ir
mlir.dialects._tosa_ops_gen.cond_if(output_list, condition, input_list, *, loc=None, ip=None) _ods_ir | _ods_ir | IfOp
class mlir.dialects._tosa_ops_gen.IntDivOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise integer divide of input1 by input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match. The result of the divide is truncated towards zero. Expected use is for operations on non-scaled integers. Floating point divide should use RECIPROCAL and MUL. Quantized integer divide should use TABLE (for 1/x) and MUL.

OPERATION_NAME = 'tosa.intdiv'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.intdiv(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise natural logarithm operation

OPERATION_NAME = 'tosa.log'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.log(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalAndOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical AND of input1 and input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.logical_and'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_and(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalLeftShiftOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical left-shift of input1 by the amount specified in input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.logical_left_shift'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_left_shift(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalNotOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical NOT of input.

OPERATION_NAME = 'tosa.logical_not'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_not(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalOrOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical OR of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.logical_or'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_or(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalRightShiftOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical right shift of input1 by the amount specified in input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.logical_right_shift'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_right_shift(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.LogicalXorOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise logical XOR of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.logical_xor'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.logical_xor(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MatMulOp(output, a, b, a_zp, b_zp, *, loc=None, ip=None)

Bases: _ods_ir

Performs two dimensional matrix multiplications.

OPERATION_NAME = 'tosa.matmul'
_ODS_REGIONS = (0, True)
a() _ods_ir
b() _ods_ir
a_zp() _ods_ir
b_zp() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.matmul(output, a, b, a_zp, b_zp, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MatmulTBlockScaledOp(output_data, a_data, a_scale, b_data, b_scale, block_size, *, loc=None, ip=None)

Bases: _ods_ir

Performs two dimensional matrix multiplications using block scaled tensors. The block dimension is always the the last dimension of the tensor, so the result is effectively a matrix multiply of A by the transposed B matrix. If the N dimension of input B is of size 1, the B matrix will be broadcast.

OPERATION_NAME = 'tosa.matmul_t_block_scaled'
_ODS_REGIONS = (0, True)
a_data() _ods_ir
a_scale() _ods_ir
b_data() _ods_ir
b_scale() _ods_ir
block_size() _ods_ir
output_data() _ods_ir
mlir.dialects._tosa_ops_gen.matmul_t_block_scaled(output_data, a_data, a_scale, b_data, b_scale, block_size, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MaxPool2dOp(output, input, kernel, stride, pad, *, nan_mode=None, loc=None, ip=None)

Bases: _ods_ir

This performs a max pooling over the given input tensor. A sliding window of size given by is passed over the input tensor, with the maximum value being placed in the output tensor.

OPERATION_NAME = 'tosa.max_pool2d'
_ODS_REGIONS = (0, True)
input() _ods_ir
kernel() _ods_ir
stride() _ods_ir
pad() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.max_pool2d(output, input, kernel, stride, pad, *, nan_mode=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MaximumOp(output, input1, input2, *, nan_mode=None, loc=None, ip=None)

Bases: _ods_ir

Elementwise max of input1 and input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.maximum'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.maximum(output, input1, input2, *, nan_mode=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MinimumOp(output, input1, input2, *, nan_mode=None, loc=None, ip=None)

Bases: _ods_ir

Elementwise minimum of input1 and input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.minimum'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.minimum(output, input1, input2, *, nan_mode=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.MulOp(output, input1, input2, shift, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise multiplication (Hadamard product) of input1 and input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.mul'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
shift() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.mul(output, input1, input2, shift, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.NegateOp(output, input1, input1_zp, output_zp, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise negation operation.

OPERATION_NAME = 'tosa.negate'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input1_zp() _ods_ir
output_zp() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.negate(output, input1, input1_zp, output_zp, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.PadOp(output, input1, padding, pad_const, *, loc=None, ip=None)

Bases: _ods_ir

Pads a tensor along the borders of each dimension with a supplied value. Returns a new tensor with the padding included. The pad_const value includes the zero point if the tensor uses a zero point.

Example:

%pad_const = "tosa.const"() {values = dense<3.14> : tensor<1xf32>} : () -> tensor<1xf32>
%padding = tosa.const_shape {values = dense<[1, 2, 3, 4]> : tensor<4xindex>} : () -> !tosa.shape<4>
tosa.pad %arg0, %padding, %pad_const: (tensor<1x2xf32>, !tosa.shape<4>, tensor<1xf32>)  -> (tensor<4x9xf32>)

Example 2:

%pad_const = "tosa.const"() {values = dense<3.14> : tensor<1xf32>} : () -> tensor<1xf32>
%padding = tosa.const_shape {values = dense<[-1, 2, 3, 4]> : tensor<4xindex>} : () -> !tosa.shape<4>
tosa.pad %arg0, %padding, %pad_const : (tensor<1x2xf32>, !tosa.shape<4>, tensor<1xf32>)  -> (tensor<?x9xf32>)
OPERATION_NAME = 'tosa.pad'
_ODS_REGIONS = (0, True)
input1() _ods_ir
padding() _ods_ir
pad_const() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.pad(output, input1, padding, pad_const, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.PowOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise input1 value raised to the power of input2. Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.pow'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.pow(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.RFFT2dOp(output_real, output_imag, input_real, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs a batched 2D real-valued Fast Fourier Transform over the input where the input tensor consists of real values producing complex valued output. The complex output values will be split into the output_real and output_imag tensor arguments. RFFT2D takes advantage of Hermitian symmetry to only calculate the first half of the final output axis. Implementations may choose to skip calculation of the imaginary values at (0,0), (0,W/2), (H/2,0), and (H/2, W/2). If the calculation is skipped, the result at that location must be zero.

Example:

%ouput_real, %output_imag = tosa.rfft2d %input_real : (tensor<8x16xf32>) -> (tensor<8x9xf32>, tensor<8x9xf32>)
OPERATION_NAME = 'tosa.rfft2d'
_ODS_REGIONS = (0, True)
input_real() _ods_ir
local_bound() _ods_ir | None
output_real() _ods_ir
output_imag() _ods_ir
mlir.dialects._tosa_ops_gen.rfft2d(output_real, output_imag, input_real, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReciprocalOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise reciprocal operation. For integer operation, a TABLE should be used with the appropriate ranges.

OPERATION_NAME = 'tosa.reciprocal'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reciprocal(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceAllOp(input, axis, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis with a logical AND operation.

OPERATION_NAME = 'tosa.reduce_all'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_all(input, axis, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceAnyOp(input, axis, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis with a logical OR operation.

OPERATION_NAME = 'tosa.reduce_any'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_any(input, axis, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceMaxOp(input, axis, *, nan_mode=None, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis with a maximum operation.

OPERATION_NAME = 'tosa.reduce_max'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_max(input, axis, *, nan_mode=None, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceMinOp(input, axis, *, nan_mode=None, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis with a minimum operation.

OPERATION_NAME = 'tosa.reduce_min'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
nan_mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_min(input, axis, *, nan_mode=None, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceProductOp(input, axis, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis by computing the product of the axis.

OPERATION_NAME = 'tosa.reduce_product'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_product(input, axis, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReduceSumOp(input, axis, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Reduce a tensor along the given axis by computing the sum of the axis.

OPERATION_NAME = 'tosa.reduce_sum'
_ODS_REGIONS = (0, True)
input() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reduce_sum(input, axis, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.RescaleOp(output, input, multiplier, shift, input_zp, output_zp, scale32, rounding_mode, per_channel, input_unsigned, output_unsigned, *, loc=None, ip=None)

Bases: _ods_ir

RESCALE is defined using an integer multiply, add, and shift.

Rescale supports two precisions of multiplier: 16-bit and 32-bit. The 32-bit multiplier version supports two rounding modes to enable simpler lowering of existing frameworks that use two stage rounding. All arithmetic is designed so that it does not overflow a 64-bit accumulator and that the result fits in 32 bits. In particular, a 48-bit value cannot be scaled with the 32-bit multiplier because the accumulator would need to have 80 bits.

The shift and value range are limited to allow a variety of implementations. The limit of 62 on shift allows the shift to be decomposed as two right shifts of 31.

Supported rescalings:

  • This table is showing the supported conversions from the TOSA Specification.

  • The MLIR dialect here can be used to represent other conversions.

Mode | Input | Output | Unsigned input | Unsigned output |

|------------------------|——-|--------|—————-|-----------------| | signed 16 to 16 | int16 | int16 | false | false | | signed 16 to 32 | int16 | int32 | false | false | | signed 16 to 8 | int16 | int8 | false | false | | signed 32 to 16 | int32 | int16 | false | false | | signed 32 to 32 | int32 | int32 | false | false | | signed 32 to 8 | int32 | int8 | false | false | | signed 8 to 16 | int8 | int16 | false | false | | signed 8 to 32 | int8 | int32 | false | false | | signed 8 to 8 | int8 | int8 | false | false | | signed 48 to 16 | int48 | int16 | false | false | | signed 48 to 32 | int48 | int32 | false | false | | signed 48 to 8 | int48 | int8 | false | false | | unsigned 8 to signed 8 | uint8 | int8 | true | false | | signed 8 to unsigned 8 | int8 | uint8 | false | true |

OPERATION_NAME = 'tosa.rescale'
_ODS_REGIONS = (0, True)
input() _ods_ir
multiplier() _ods_ir
shift() _ods_ir
input_zp() _ods_ir
output_zp() _ods_ir
scale32() _ods_ir
rounding_mode() _ods_ir
per_channel() _ods_ir
input_unsigned() _ods_ir
output_unsigned() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.rescale(output, input, multiplier, shift, input_zp, output_zp, scale32, rounding_mode, per_channel, input_unsigned, output_unsigned, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReshapeOp(input1, shape, *, results=None, loc=None, ip=None)

Bases: _ods_ir

Returns a tensor with the same type/values as the input, with a new shape specified by the shape argument. Reshape may operate on tensors of any rank. No data conversion happens during a reshape operation.

OPERATION_NAME = 'tosa.reshape'
_ODS_REGIONS = (0, True)
input1() _ods_ir
shape() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reshape(input1, shape, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ResizeOp(output, input, scale, offset, border, mode, *, loc=None, ip=None)

Bases: _ods_ir

Resizes a tensor. Resize is only allowed in the H and W dimensions.

The height dimension is scaled by factor (scale_y_n/scale_y_d). The width dimension is scaled by factor (scale_x_n/scale_x_d).

The NEAREST_NEIGHBOR mode returns the value of the input tensor closest to the calculated sample position for both floating-point and integer data formats.

Floating-point BILINEAR mode returns a bilinearly interpolated output value based on the four closest input sample positions.

For integer BILINEAR interpolation mode, the output value must be scaled by 1/(scale_y_n * scale_x_n) in a following operation to complete the interpolation (for example with a RESCALE operator).

The output dimensions can be derived from the input dimensions by inverting the scale as described in the pseudocode. The [border_y, border_x] values adjust the output size to allow fractional sampling beyond integer input position (IH - 1,IW - 1).

The limit MAX_SCALE is applied to each scale ratio after reduction of the ratio. Individual scale numerator and denominator values are allowed to be larger than MAX_SCALE.

OPERATION_NAME = 'tosa.resize'
_ODS_REGIONS = (0, True)
input() _ods_ir
scale() _ods_ir
offset() _ods_ir
border() _ods_ir
mode() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.resize(output, input, scale, offset, border, mode, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ReverseOp(output, input1, axis, *, loc=None, ip=None)

Bases: _ods_ir

Returns a tensor with the same type/values as the input, with the data reversed along the given axis. No data conversion happens during a reverse operation.

OPERATION_NAME = 'tosa.reverse'
_ODS_REGIONS = (0, True)
input1() _ods_ir
axis() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.reverse(output, input1, axis, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.RsqrtOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise reciprocal square root operation. For integer operation, a TABLE should be used with the appropriate ranges.

OPERATION_NAME = 'tosa.rsqrt'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.rsqrt(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.ScatterOp(values_out, values_in, indices, input, *, loc=None, ip=None)

Bases: _ods_ir

The values_out tensor is set to the values_in tensor with data modified as follows: data from the input tensor is inserted at the positions specified by the indices tensor. N is the number of batches, W the number of indices in each batch, K the range of each index and C the number data channels for each index. It is not permitted to repeat the same output index within a single SCATTER operation and so each output index occurs at most once. It follows that K >= W. In use cases that require multiple updates to the same output position, these must be decomposed into multiple SCATTER operations.

OPERATION_NAME = 'tosa.scatter'
_ODS_REGIONS = (0, True)
values_in() _ods_ir
indices() _ods_ir
input() _ods_ir
values_out() _ods_ir
mlir.dialects._tosa_ops_gen.scatter(values_out, values_in, indices, input, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.SelectOp(output, input1, input2, input3, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise select of the output based on a condition.

OPERATION_NAME = 'tosa.select'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
input3() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.select(output, input1, input2, input3, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.SigmoidOp(output, input, *, loc=None, ip=None)

Bases: _ods_ir

Applies the sigmoid logistic function to each element of the input tensor: $ sigmoid(x) = frac{1}{1 + e^{-x}} $.

For quantized integer data types, the TABLE operator should be used instead. Each implementation may choose an appropriate TABLE given the scale and zero point of the input data. Eight or sixteen bit precision tables may be used based on the input tensor to the sigmoid function.

OPERATION_NAME = 'tosa.sigmoid'
_ODS_REGIONS = (0, True)
input() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.sigmoid(output, input, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.SinOp(output, input1, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise sine operation for values given in radians.

OPERATION_NAME = 'tosa.sin'
_ODS_REGIONS = (0, True)
input1() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.sin(output, input1, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.SliceOp(output, input1, start, size, *, loc=None, ip=None)

Bases: _ods_ir

Extracts a slice of input1, beginning at the start coordinates, and extending for size elements in each direction. No data conversion happens during a slice operation.

OPERATION_NAME = 'tosa.slice'
_ODS_REGIONS = (0, True)
input1() _ods_ir
start() _ods_ir
size() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.slice(output, input1, start, size, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.SubOp(output, input1, input2, *, loc=None, ip=None)

Bases: _ods_ir

Elementwise subtraction of input1 and input2. Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.

OPERATION_NAME = 'tosa.sub'
_ODS_REGIONS = (0, True)
input1() _ods_ir
input2() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.sub(output, input1, input2, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.TableOp(output, input1, table, *, loc=None, ip=None)

Bases: _ods_ir

Table lookup operation. For int8_t TABLE operation, perform a 256 entry table lookup returning an int8_t value. For int16_t tables, the int16_t input is treated as a fixed-point 9.7 value. The most significant 9 bits are used to index into the table. The fractional 7 bits are used to interpolate based on table[index] and table[index+1]. For int16_t inputs, the TABLE operator returns a 16.7 interpolated value in an int32_t. This value can then be input to the RESCALE operator to scale to the required output data type. Note that int16_t table has 513 values to handle table[index+1] when index=511.

An int16_t to int16_t table lookup can be constructed in TOSA as follows:

  • Use the TABLE operator to produce a fixed point 16.7 interpolated result

  • Use RESCALE (in_t=int32_t, out_t=int16_t, scale=1<<14, shift=21) to

scale the output to int16_t range (or alternate scale as required)

OPERATION_NAME = 'tosa.table'
_ODS_REGIONS = (0, True)
input1() _ods_ir
table() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.table(output, input1, table, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.TanhOp(output, input, *, loc=None, ip=None)

Bases: _ods_ir

Parameterized hyperbolic tangent: $ tanh(x) = frac{1 - e^{-2x}}{1 + e^{-2x}} $.

For quantized integer data types, the TABLE operator should be used instead. Each implementation may choose an appropriate TABLE given the scale and zero point of the input data. Eight or sixteen bit precision tables may be used based on the input tensor to the tanh function.

OPERATION_NAME = 'tosa.tanh'
_ODS_REGIONS = (0, True)
input() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.tanh(output, input, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.TileOp(output, input1, multiples, *, loc=None, ip=None)

Bases: _ods_ir

Replicates input1 multiples times along each dimension.

OPERATION_NAME = 'tosa.tile'
_ODS_REGIONS = (0, True)
input1() _ods_ir
multiples() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.tile(output, input1, multiples, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.TransposeConv2DOp(output, input, weight, bias, input_zp, weight_zp, out_pad, stride, acc_type, *, local_bound=None, loc=None, ip=None)

Bases: _ods_ir

Performs a 2D transposed convolution over the given tensor input, using the weights tensor. Implementations may choose to skip calculation of multiplies by zero at fractional input positions.

OPERATION_NAME = 'tosa.transpose_conv2d'
_ODS_REGIONS = (0, True)
input() _ods_ir
weight() _ods_ir
bias() _ods_ir
input_zp() _ods_ir
weight_zp() _ods_ir
out_pad() _ods_ir
stride() _ods_ir
acc_type() _ods_ir
local_bound() _ods_ir | None
output() _ods_ir
mlir.dialects._tosa_ops_gen.transpose_conv2d(output, input, weight, bias, input_zp, weight_zp, out_pad, stride, acc_type, *, local_bound=None, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.TransposeOp(output, input1, perms, *, loc=None, ip=None)

Bases: _ods_ir

Permutes the dimensions of the input tensor input1 based on the perms argument. Each value in the perms list must be a valid dimension of the input tensor and may not be repeated.

OPERATION_NAME = 'tosa.transpose'
_ODS_REGIONS = (0, True)
input1() _ods_ir
perms() _ods_ir
output() _ods_ir
mlir.dialects._tosa_ops_gen.transpose(output, input1, perms, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.VariableOp(sym_name, var_shape, type_, *, initial_value=None, loc=None, ip=None)

Bases: _ods_ir

Defines a new TOSA variable. This is a persistent mutable value across multiple TOSA graph invocations. Modifications are expressed using read/write semantics.

OPERATION_NAME = 'tosa.variable'
_ODS_REGIONS = (0, True)
sym_name() _ods_ir
var_shape() _ods_ir
type_() _ods_ir
initial_value() _ods_ir | None
mlir.dialects._tosa_ops_gen.variable(sym_name, var_shape, type_, *, initial_value=None, loc=None, ip=None) VariableOp
class mlir.dialects._tosa_ops_gen.VariableReadOp(output1, name, *, loc=None, ip=None)

Bases: _ods_ir

Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.

OPERATION_NAME = 'tosa.variable_read'
_ODS_REGIONS = (0, True)
name() _ods_ir

Returns the fully qualified name of the operation.

output1() _ods_ir
mlir.dialects._tosa_ops_gen.variable_read(output1, name, *, loc=None, ip=None) _ods_ir
class mlir.dialects._tosa_ops_gen.VariableWriteOp(name, input1, *, loc=None, ip=None)

Bases: _ods_ir

Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.

OPERATION_NAME = 'tosa.variable_write'
_ODS_REGIONS = (0, True)
input1() _ods_ir
name() _ods_ir

Returns the fully qualified name of the operation.

mlir.dialects._tosa_ops_gen.variable_write(name, input1, *, loc=None, ip=None) VariableWriteOp
class mlir.dialects._tosa_ops_gen.WhileOp(output_list, input_list, *, loc=None, ip=None)

Bases: _ods_ir

Generates and evaluates a Boolean condition and either executes a loop body or exits the loop. This action is performed repeatedly after updating and re-evaluating the Boolean condition every iteration. This implements the semantic foreach or while iterative loop structure.

OPERATION_NAME = 'tosa.while_loop'
_ODS_REGIONS = (2, True)
input_list() _ods_ir
output_list() _ods_ir
cond_graph() _ods_ir
body_graph() _ods_ir
mlir.dialects._tosa_ops_gen.while_loop(output_list, input_list, *, loc=None, ip=None) _ods_ir | _ods_ir | WhileOp
class mlir.dialects._tosa_ops_gen.YieldOp(inputs, *, loc=None, ip=None)

Bases: _ods_ir

return operation within the conditional and body of structured control flow. Operation takes variadic operands but produces no results of its own.

OPERATION_NAME = 'tosa.yield'
_ODS_REGIONS = (0, True)
inputs() _ods_ir
mlir.dialects._tosa_ops_gen.yield_(inputs, *, loc=None, ip=None) YieldOp