Beaver.MLIR.Dialect.TOSA (beaver v0.4.7)

Summary

Functions

tosa.abs - Elementwise abs operator.

tosa.add - Elementwise addition operator.

tosa.apply_scale - Rescale scalar operator for Tosa tensor operators

tosa.argmax - Perform argmax on the input.

tosa.arithmetic_right_shift - Elementwise Arithmetic Right Shift.

tosa.avg_pool2d - Performs average pooling on the input.

tosa.bitwise_and - Bitwise AND operator.

tosa.bitwise_not - Bitwise NOT operator.

tosa.bitwise_or - Bitwise OR operator.

tosa.bitwise_xor - Bitwise XOR operator.

tosa.cast - Cast operation.

tosa.ceil - Elementwise ceil operator.

tosa.clamp - Computes clamp(features, min, max).

tosa.clz - Elementwise count leading zero operator.

tosa.concat - Concatenates tensors along one dimension.

tosa.cond_if - Conditional if operator.

tosa.const

tosa.const_shape

tosa.conv2d - 2D Convolution operator.

tosa.conv3d - 3D Convolution operator.

tosa.cos - Elementwise cos operator.

tosa.custom - Custom operator wrapper for Tosa

tosa.depthwise_conv2d - Depthwise 2D Convolution operator.

tosa.equal - Returns the truth value of (input1 == input2) element-wise.

tosa.erf - Computes gauss error function of input.

tosa.exp - Elementwise exp operator.

tosa.fft2d - Performs FFT2D operation on the input.

tosa.floor - Elementwise floor operator.

tosa.gather - Gather operation.

tosa.greater - Returns the truth value of (input1 > input2) element-wise.

tosa.greater_equal - Returns the truth value of (input1 >= input2) element-wise.

tosa.identity - Identity operator.

tosa.intdiv - Integer divide operator.

tosa.log - Elementwise log operator.

tosa.logical_and - Returns the truth value of input1 AND input2 element-wise.

tosa.logical_left_shift - Elementwise Logical Left Shift.

tosa.logical_not - Returns the truth value of NOT input1 element-wise.

tosa.logical_or - Returns the truth value of x OR y element-wise.

tosa.logical_right_shift - Elementwise Logical Right Shift.

tosa.logical_xor - Returns the truth value of input1 XOR input2 element-wise.

tosa.matmul - Matrix multiplication operator.

tosa.max_pool2d - Performs max pooling on the input.

tosa.maximum - Elementwise Maximum.

tosa.minimum - Elementwise Minimum.

tosa.mul - Multiplication operator.

tosa.negate - Elementwise negate operator.

tosa.pad - Pads a tensor with value specified.

tosa.pow - Computes the power of one value to another.

tosa.reciprocal - Elementwise reciprocal operator.

tosa.reduce_all - Reduce All operator.

tosa.reduce_any - Reduce Any operator.

tosa.reduce_max - Reduce Max operator.

tosa.reduce_min - Reduce Min operator.

tosa.reduce_product - Reduce Product operator.

tosa.reduce_sum - Reduce Sum operator.

tosa.rescale - Tosa rescale operator.

tosa.reshape - Reshape operator.

tosa.resize - Resize operation, supports various resize/upsample modes.

tosa.reverse - Reverse operator.

tosa.rfft2d - Performs RFFT2D operation on the input.

tosa.rsqrt - Elementwise 1/sqrt operator.

tosa.scatter - Scatter operation.

tosa.select - Elementwise select operator.

tosa.sigmoid - Computes elementwise sigmoid of input.

tosa.sin - Elementwise sin operator.

tosa.slice - Slice operator.

tosa.sub - Elementwise subtraction operator.

tosa.table - Table lookup operator.

tosa.tanh - Computes elementwise hyperbolic tangent of input.

tosa.tile - Tile operator.

tosa.transpose - Transpose operator.

tosa.transpose_conv2d - Transpose 2D Convolution operator.

tosa.variable

tosa.variable_read

tosa.variable_write - write_buffer operator

tosa.while_loop - output = input; While (Cond(output)) {output = Body(output)}

tosa.yield - yield operator

Functions

abs(ssa)

tosa.abs - Elementwise abs operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise absolute value operation.

Example:

%output = tosa.abs(%input1) : (tensor<21x3xf32>) -> tensor<21x3xf32>

add(ssa)

tosa.add - Elementwise addition operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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>

apply_scale(ssa)

tosa.apply_scale - Rescale scalar operator for Tosa tensor operators

Attributes

  • rounding_mode - Single, Tosa_RoundingModeAttr, Supported rounding modes

Operands

  • value - Single, Tosa_IntLike, signless-integer-like
  • multiplier - Single, Tosa_IntLike, signless-integer-like
  • shift - Single, Tosa_Int8Like, signless-integer-8-bit-like

Results

  • output - Single, Tosa_IntLike, signless-integer-like

Description

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.

argmax(ssa)

tosa.argmax - Perform argmax on the input.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute
  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

arithmetic_right_shift(ssa)

tosa.arithmetic_right_shift - Elementwise Arithmetic Right Shift.

Attributes

  • round - Single, BoolAttr, bool attribute

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

avg_pool2d(ssa)

tosa.avg_pool2d - Performs average pooling on the input.

Attributes

  • kernel - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • stride - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • pad - Single, Tosa_IntArrayAttr4, i64 dense array attribute with exactly 4 elements
  • acc_type - Single, anonymous/composite constraint, type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • output_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

This performs an average pooling over the given input tensor. A sliding window of size given by <kernel size> 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.

bitwise_and(ssa)

tosa.bitwise_and - Bitwise AND operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

bitwise_not(ssa)

tosa.bitwise_not - Bitwise NOT operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise bitwise NOT of input tensor.

bitwise_or(ssa)

tosa.bitwise_or - Bitwise OR operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

bitwise_xor(ssa)

tosa.bitwise_xor - Bitwise XOR operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

cast(ssa)

tosa.cast - Cast operation.

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.
ModeInputOutput
fp16 to fp32float16float32
fp16 to int 16float16int16
fp16 to int 32float16int32
fp16 to int 8float16int8
fp32 to fp16float32float16
fp32 to int 16float32int16
fp32 to int 32float32int32
fp32 to int 8float32int8
int 16 to fp16int16float16
int 16 to fp32int16float32
int 32 to fp16int32float16
int 32 to fp32int32float32
int 8 to fp16int8float16
int 8 to fp32int8float32
bool to int 16Booleanint16
bool to int 32Booleanint32
bool to int 8Booleanint8
int 16 to boolint16Boolean
int 16 to int 32int16int32
int 16 to int 8int16int8
int 32 to boolint32Boolean
int 32 to int 16int32int16
int 32 to int 8int32int8
int 8 to boolint8Boolean
int 8 to int 16int8int16
int 8 to int 32int8int32
bf16 to fp32bf16float32
bf16 to int 16bf16int16
bf16 to int 32bf16int32
bf16 to int 8bf16int8
fp32 to bf16float32bf16
int 16 to bf16int16bf16
int 32 to bf16int32bf16
int 8 to bf16int8bf16
bf16 to fp8e4m3bf16fp8e4m3
fp8e4m3 to bf16fp8e4m3bf16
bf16 to fp8e5m2bf16fp8e5m2
fp8e5m2 to bf16fp8e5m2bf16
fp16 to fp8e4m3float16fp8e4m3
fp32 to fp8e4m3float32fp8e4m3
fp8e4m3 to fp16fp8e4m3float16
fp8e4m3 to fp32fp8e4m3float32
fp16 to fp8e5m2float16fp8e5m2
fp32 to fp8e5m2float32fp8e5m2
fp8e5m2 to fp16fp8e5m2float16
fp8e5m2 to fp32fp8e5m2float32

ceil(ssa)

tosa.ceil - Elementwise ceil operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise ceiling operation.

clamp(ssa)

tosa.clamp - Computes clamp(features, min, max).

Attributes

  • min_val - Single, Tosa_IntOrFloatAttr, arbitrary integer attribute or arbitrary float attribute
  • max_val - Single, Tosa_IntOrFloatAttr, arbitrary integer attribute or arbitrary float attribute
  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

clz(ssa)

tosa.clz - Elementwise count leading zero operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise count leading zeros operation.

concat(ssa)

tosa.concat - Concatenates tensors along one dimension.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input1 - Variadic, Tosa_TensorAtLeast1D, variadic of tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

cond_if(ssa)

tosa.cond_if - Conditional if operator.

Operands

  • condition - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values
  • input_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Results

  • output_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Description

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

const(ssa)

tosa.const

const_shape(ssa)

tosa.const_shape

conv2d(ssa)

tosa.conv2d - 2D Convolution operator.

Attributes

  • pad - Single, Tosa_IntArrayAttr4, i64 dense array attribute with exactly 4 elements
  • stride - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • dilation - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • acc_type - Single, anonymous/composite constraint, type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float
  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • weight - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • bias - Single, Tosa_Tensor1D, 1-d tosa-conformant tensor
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • weight_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

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.

conv3d(ssa)

tosa.conv3d - 3D Convolution operator.

Attributes

  • pad - Single, Tosa_IntArrayAttr6, i64 dense array attribute with exactly 6 elements
  • stride - Single, Tosa_IntArrayAttr3, i64 dense array attribute with exactly 3 elements
  • dilation - Single, Tosa_IntArrayAttr3, i64 dense array attribute with exactly 3 elements
  • acc_type - Single, anonymous/composite constraint, type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float
  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input - Single, Tosa_Tensor5D, 5-d tosa-conformant tensor
  • weight - Single, Tosa_Tensor5D, 5-d tosa-conformant tensor
  • bias - Single, Tosa_Tensor1D, 1-d tosa-conformant tensor
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • weight_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor5D, 5-d tosa-conformant tensor

Description

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

cos(ssa)

tosa.cos - Elementwise cos operator.

Operands

  • input1 - Single, Tosa_FloatTensor, tosa-conformant tensor of floating-point values

Results

  • output - Single, Tosa_FloatTensor, tosa-conformant tensor of floating-point values

Description

Elementwise cosine operation for values given in radians.

custom(ssa)

tosa.custom - Custom operator wrapper for Tosa

Attributes

  • operator_name - Single, StrAttr, string attribute
  • domain_name - Single, StrAttr, string attribute
  • implementation_attrs - Single, StrAttr, string attribute

Operands

  • input_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Results

  • output_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Description

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>)

depthwise_conv2d(ssa)

tosa.depthwise_conv2d - Depthwise 2D Convolution operator.

Attributes

  • pad - Single, Tosa_IntArrayAttr4, i64 dense array attribute with exactly 4 elements
  • stride - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • dilation - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • acc_type - Single, anonymous/composite constraint, type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float
  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • weight - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • bias - Single, Tosa_Tensor1D, 1-d tosa-conformant tensor
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • weight_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

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.

equal(ssa)

tosa.equal - Returns the truth value of (input1 == input2) element-wise.

This op has support for result type inference.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

Elementwise comparison operation.

erf(ssa)

tosa.erf - Computes gauss error function of input.

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

exp(ssa)

tosa.exp - Elementwise exp operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise e to the x operation

fft2d(ssa)

tosa.fft2d - Performs FFT2D operation on the input.

Attributes

  • inverse - Single, BoolAttr, bool attribute
  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input_real - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • input_imag - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Results

  • output_real - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • output_imag - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Description

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>)

floor(ssa)

tosa.floor - Elementwise floor operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise floor operation.

gather(ssa)

tosa.gather - Gather operation.

Operands

  • values - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • indices - Single, Tosa_Int32Tensor2D, tosa-conformant unranked tensor of number values or 2D tensor of 32-bit signless integer values

Results

  • output - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Description

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.

greater(ssa)

tosa.greater - Returns the truth value of (input1 > input2) element-wise.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

Elementwise greater than comparison operation.

greater_equal(ssa)

tosa.greater_equal - Returns the truth value of (input1 >= input2) element-wise.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

Elementwise comparison operation.

identity(ssa)

tosa.identity - Identity operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

intdiv(ssa)

tosa.intdiv - Integer divide operator.

Operands

  • input1 - Single, Tosa_Int32Tensor, tosa-conformant tensor of 32-bit signless integer values
  • input2 - Single, Tosa_Int32Tensor, tosa-conformant tensor of 32-bit signless integer values

Results

  • output - Single, Tosa_Int32Tensor, tosa-conformant tensor of 32-bit signless integer values

Description

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.

log(ssa)

tosa.log - Elementwise log operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise natural logarithm operation

logical_and(ssa)

tosa.logical_and - Returns the truth value of input1 AND input2 element-wise.

Operands

  • input1 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values
  • input2 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

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

logical_left_shift(ssa)

tosa.logical_left_shift - Elementwise Logical Left Shift.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

logical_not(ssa)

tosa.logical_not - Returns the truth value of NOT input1 element-wise.

Operands

  • input1 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

Elementwise logical NOT of input.

logical_or(ssa)

tosa.logical_or - Returns the truth value of x OR y element-wise.

Operands

  • input1 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values
  • input2 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

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

logical_right_shift(ssa)

tosa.logical_right_shift - Elementwise Logical Right Shift.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

logical_xor(ssa)

tosa.logical_xor - Returns the truth value of input1 XOR input2 element-wise.

Operands

  • input1 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values
  • input2 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Results

  • output - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values

Description

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

matmul(ssa)

tosa.matmul - Matrix multiplication operator.

Operands

  • a - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • b - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • a_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • b_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Description

Performs two dimensional matrix multiplications.

max_pool2d(ssa)

tosa.max_pool2d - Performs max pooling on the input.

Attributes

  • kernel - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • stride - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • pad - Single, Tosa_IntArrayAttr4, i64 dense array attribute with exactly 4 elements
  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

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

maximum(ssa)

tosa.maximum - Elementwise Maximum.

Attributes

  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

minimum(ssa)

tosa.minimum - Elementwise Minimum.

Attributes

  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

mul(ssa)

tosa.mul - Multiplication operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • shift - Single, Tosa_ScalarInt8Tensor, tosa-conformant unranked tensor of 8-bit signless integer values or tosa-conformant scalar tensor of 8-bit signless integer values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

negate(ssa)

tosa.negate - Elementwise negate operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input1_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • output_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise negation operation.

pad(ssa)

tosa.pad - Pads a tensor with value specified.

Operands

  • input1 - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1
  • padding - Single, Tosa_Shape, Shape with static rank and Index element type
  • pad_const - Single, Tosa_ScalarTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of number values

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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>)

pow(ssa)

tosa.pow - Computes the power of one value to another.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

reciprocal(ssa)

tosa.reciprocal - Elementwise reciprocal operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

reduce_all(ssa)

tosa.reduce_all - Reduce All operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

reduce_any(ssa)

tosa.reduce_any - Reduce Any operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

reduce_max(ssa)

tosa.reduce_max - Reduce Max operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute
  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

reduce_min(ssa)

tosa.reduce_min - Reduce Min operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute
  • nan_mode - Single, Tosa_NanPropagationModeAttr, Supported NaN propagation strategies

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

reduce_product(ssa)

tosa.reduce_product - Reduce Product operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

reduce_sum(ssa)

tosa.reduce_sum - Reduce Sum operator.

This op has support for result type inference.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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

rescale(ssa)

tosa.rescale - Tosa rescale operator.

Attributes

  • scale32 - Single, BoolAttr, bool attribute
  • rounding_mode - Single, Tosa_RoundingModeAttr, Supported rounding modes
  • per_channel - Single, BoolAttr, bool attribute
  • input_unsigned - Single, BoolAttr, bool attribute
  • output_unsigned - Single, BoolAttr, bool attribute

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • multiplier - Single, Tosa_1DInt16Or32Tensor, 1D tensor of 16-bit signless integer or 32-bit signless integer values
  • shift - Single, Tosa_1DInt8Tensor, 1D tensor of 8-bit signless integer values
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • output_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.
ModeInputOutputUnsigned inputUnsigned output
signed 16 to 16int16int16falsefalse
signed 16 to 32int16int32falsefalse
signed 16 to 8int16int8falsefalse
signed 32 to 16int32int16falsefalse
signed 32 to 32int32int32falsefalse
signed 32 to 8int32int8falsefalse
signed 8 to 16int8int16falsefalse
signed 8 to 32int8int32falsefalse
signed 8 to 8int8int8falsefalse
signed 48 to 16int48int16falsefalse
signed 48 to 32int48int32falsefalse
signed 48 to 8int48int8falsefalse
unsigned 8 to signed 8uint8int8truefalse
signed 8 to unsigned 8int8uint8falsetrue

reshape(ssa)

tosa.reshape - Reshape operator.

This op has support for result type inference.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • shape - Single, Tosa_Shape, Shape with static rank and Index element type

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

resize(ssa)

tosa.resize - Resize operation, supports various resize/upsample modes.

Attributes

  • mode - Single, Tosa_ResizeModeAttr, Supported resize/upsampling strategies

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • scale - Single, Rank4TosaShape, Tosa shape type of rank 4
  • offset - Single, Rank2TosaShape, Tosa shape type of rank 2
  • border - Single, Rank2TosaShape, Tosa shape type of rank 2

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

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.

reverse(ssa)

tosa.reverse - Reverse operator.

Attributes

  • axis - Single, I32Attr, 32-bit signless integer attribute

Operands

  • input1 - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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.

rfft2d(ssa)

tosa.rfft2d - Performs RFFT2D operation on the input.

Attributes

  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input_real - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Results

  • output_real - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • output_imag - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Description

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>)

rsqrt(ssa)

tosa.rsqrt - Elementwise 1/sqrt operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

scatter(ssa)

tosa.scatter - Scatter operation.

Operands

  • values_in - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor
  • indices - Single, Tosa_Int32Tensor2D, tosa-conformant unranked tensor of number values or 2D tensor of 32-bit signless integer values
  • input - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Results

  • values_out - Single, Tosa_Tensor3D, 3-d tosa-conformant tensor

Description

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.

select(ssa)

tosa.select - Elementwise select operator.

Operands

  • input1 - Single, Tosa_I1Tensor, tosa-conformant tensor of 1-bit signless integer values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input3 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

Elementwise select of the output based on a condition.

sigmoid(ssa)

tosa.sigmoid - Computes elementwise sigmoid of input.

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

sin(ssa)

tosa.sin - Elementwise sin operator.

Operands

  • input1 - Single, Tosa_FloatTensor, tosa-conformant tensor of floating-point values

Results

  • output - Single, Tosa_FloatTensor, tosa-conformant tensor of floating-point values

Description

Elementwise sine operation for values given in radians.

slice(ssa)

tosa.slice - Slice operator.

Operands

  • input1 - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1
  • start - Single, Tosa_Shape, Shape with static rank and Index element type
  • size - Single, Tosa_Shape, Shape with static rank and Index element type

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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.

sub(ssa)

tosa.sub - Elementwise subtraction operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • input2 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

table(ssa)

tosa.table - Table lookup operator.

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values
  • table - Single, Tosa_Tensor1D, 1-d tosa-conformant tensor

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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)

tanh(ssa)

tosa.tanh - Computes elementwise hyperbolic tangent of input.

Operands

  • input - Single, Tosa_Tensor, tosa-conformant tensor of number values

Results

  • output - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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.

tile(ssa)

tosa.tile - Tile operator.

Operands

  • input1 - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1
  • multiples - Single, Tosa_Shape, Shape with static rank and Index element type

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

Replicates input1 multiples times along each dimension.

transpose(ssa)

tosa.transpose - Transpose operator.

Attributes

  • perms - Single, DenseI32ArrayAttr, i32 dense array attribute

Operands

  • input1 - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Results

  • output - Single, Tosa_TensorAtLeast1D, tosa-conformant tensor of at least rank 1

Description

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.

transpose_conv2d(ssa)

tosa.transpose_conv2d - Transpose 2D Convolution operator.

Attributes

  • out_pad - Single, Tosa_IntArrayAttr4, i64 dense array attribute with exactly 4 elements
  • stride - Single, Tosa_IntArrayAttr2, i64 dense array attribute with exactly 2 elements
  • acc_type - Single, anonymous/composite constraint, type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float
  • local_bound - Optional, BoolAttr, bool attribute

Operands

  • input - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • weight - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor
  • bias - Single, Tosa_Tensor1D, 1-d tosa-conformant tensor
  • input_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values
  • weight_zp - Single, Tosa_ScalarIntOrFloatTensor, tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values

Results

  • output - Single, Tosa_Tensor4D, 4-d tosa-conformant tensor

Description

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.

variable(ssa)

tosa.variable

variable_read(ssa)

tosa.variable_read

variable_write(ssa)

tosa.variable_write - write_buffer operator

Attributes

  • name - Single, SymbolNameAttr, string attribute

Operands

  • input1 - Single, Tosa_Tensor, tosa-conformant tensor of number values

Description

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

while_loop(ssa)

tosa.while_loop - output = input; While (Cond(output)) {output = Body(output)}

Operands

  • input_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Results

  • output_list - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Description

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.

yield(ssa)

tosa.yield - yield operator

Operands

  • inputs - Variadic, Tosa_Tensor, variadic of tosa-conformant tensor of number values

Description

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