'tfl' Dialect

The TensorFlow Lite dialect.

This dialect maps to TensorFlow Lite operations.

Invariants:

  • All values are of Tensor type (in particular, scalars are represented using zero-dimensional tensors);

Operations

tfl.abs (TFL::AbsOp)

Absolute value operator

Given a tensor x, this operation returns a tensor containing the absolute value of each element in x. For example, if x is an input element and y is an output element, this operation computes \(y = |x|\).

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 16-bit signless integer or 32-bit signless integer or 32-bit float or QI8 type or QI16 type values

Results:

Result Description
y tensor of 16-bit signless integer or 32-bit signless integer or 32-bit float or QI8 type or QI16 type values

tfl.add (TFL::AddOp)

Addition operator

Element-wise addition operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
lhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values
rhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
output tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values

tfl.add_n (TFL::AddNOp)

_Addn operator

Adds all input tensors element-wise.

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
inputs variadic of tensor of any type values

Results:

Result Description
sum tensor of 32-bit float or 32-bit signless integer values

tfl.arg_max (TFL::ArgMaxOp)

ArgMax operator

Returns the index with the largest value across dimensions of a tensor.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
output_type::mlir::Attributederived attribute

Operands:

Operand Description
input tensor of 1-bit signless integer or 32-bit float or 32-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type values
dim tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32/64-bit signless integer values

tfl.arg_min (TFL::ArgMinOp)

ArgMin operator

Returns the index with the smallest value across dimensions of a tensor. a = [1, 10, 26.9, 2.8, 166.32, 62.3] b = tf.math.argmin(input = a) c = tf.keras.backend.eval(b)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
output_type::mlir::Attributederived attribute

Operands:

Operand Description
input tensor of 1-bit signless integer or 32-bit float or 32-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type values
dim tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32/64-bit signless integer values

tfl.assign_variable (TFL::AssignVariableOp)

Assigns a new value to a variable.

Any ReadVariableOp with a control dependency on this op is guaranteed to return this value or a subsequent newer value of the variable.

Interfaces: TflRuntimeVerifyOpInterface

Operands:

Operand Description
resource_id tensor of resource values
value tensor of 32-bit float or 64-bit float or 1-bit signless integer or 8-bit unsigned integer or 8-bit signless integer or QI8 type or QUI8 type or 32-bit signless integer or 64-bit signless integer or QI16 type or complex type with 32-bit float elements or complex type with 64-bit float elements values

tfl.atan2 (TFL::Atan2Op)

Atan2 operation

The "atan2" operation computes the arctangent of y/x element-wise, respecting signs of the arguments.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultElementType, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
y tensor of 32-bit float or 64-bit float values
x tensor of 32-bit float or 64-bit float values

Results:

Result Description
output tensor of 32-bit float or 64-bit float values

tfl.average_pool_2d (TFL::AveragePool2DOp)

_Average_pool2d operator

Performs average-pooling operation on input.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
filter_height::mlir::IntegerAttr32-bit signless integer attribute
filter_width::mlir::IntegerAttr32-bit signless integer attribute
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_h::mlir::IntegerAttr32-bit signless integer attribute
stride_w::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values

tfl.basic_lstm (TFL::BasicLSTMOp)

The basic lstm operator

basic LSTM Cell Operator.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
cell_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
proj_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
kernel_type::mlir::TFL::LSTMKernelTypeAttrlstm_kernel_type whose value is mlir::TFL::LSTMKernelType::BASIC

Operands:

Operand Description
data_input tensor of 32-bit float or QUI8 type values
prev_activ_input tensor of 32-bit float or QUI8 type values
weights_input tensor of 32-bit float or QUI8 type values
biases_input tensor of 32-bit float or QI32 type values
prev_state_input tensor of 32-bit float or QI16 type values

Results:

Result Description
activ_output 2D tensor of any type values
state_output 2D tensor of any type values
concat_temp 2D tensor of any type values
activ_temp 2D tensor of any type values

tfl.batch_matmul (TFL::BatchMatMulOp)

Batch Matrix Multiply Operator

Performs a batched matrix multiplication on the inputs. Follows the conventions of TensorFlow BatchMatMulV2, with support for unknown dimensions in the batch dimensions and broadcasting.

Inputs:
  `inputs[0]`: required: input LHS
  `inputs[1]`: required: input RHS
  `adjoint_lhs`: optional: Transpose LHS (default false)
  `adjoint_lhs`: optional: Transpose LHS (default false)

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
adj_x::mlir::BoolAttrbool attribute
adj_y::mlir::BoolAttrbool attribute
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute

Operands:

Operand Description
x tensor of 32-bit float or QI8 type or QI16 type or 8-bit signless integer values
y tensor of 32-bit float or QI8 type or QI16 type or 8-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QI16 type or 32-bit signless integer values

tfl.batch_to_space_nd (TFL::BatchToSpaceNdOp)

BatchToSpaceNd operator

This operation reshapes the "batch" dimension 0 into space dimensions.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values
block_shape tensor of 32-bit signless integer values
indices tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values

tfl.bidirectional_sequence_lstm (TFL::BidirectionalSequenceLSTMOp)

Bidirectional sequence lstm operator

Bidirectional lstm is essentially two lstms, one running forward & the other running backward. And the output is the concatenation of the two lstms.

Traits: QuantizableResult

Interfaces: DynamicRangeQuantizedOpInterface, TFL_StatefulOp, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
cell_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
proj_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
merge_outputs::mlir::BoolAttrbool attribute
time_major::mlir::BoolAttrbool attribute
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer values
fw_input_to_input_weights tensor of any type values or none type
fw_input_to_forget_weights tensor of 32-bit float or 8-bit signless integer values
fw_input_to_cell_weights tensor of 32-bit float or 8-bit signless integer values
fw_input_to_output_weights tensor of 32-bit float or 8-bit signless integer values
fw_recurrent_to_input_weights tensor of any type values or none type
fw_recurrent_to_forget_weights tensor of 32-bit float or 8-bit signless integer values
fw_recurrent_to_cell_weights tensor of 32-bit float or 8-bit signless integer values
fw_recurrent_to_output_weights tensor of 32-bit float or 8-bit signless integer values
fw_cell_to_input_weights tensor of any type values or none type
fw_cell_to_forget_weights tensor of any type values or none type
fw_cell_to_output_weights tensor of any type values or none type
fw_input_gate_bias tensor of any type values or none type
fw_forget_gate_bias tensor of 32-bit float values
fw_cell_bias tensor of 32-bit float values
fw_output_gate_bias tensor of 32-bit float values
fw_projection_weights tensor of any type values or none type
fw_projection_bias tensor of any type values or none type
bw_input_to_input_weights tensor of any type values or none type
bw_input_to_forget_weights tensor of 32-bit float or 8-bit signless integer values
bw_input_to_cell_weights tensor of 32-bit float or 8-bit signless integer values
bw_input_to_output_weights tensor of 32-bit float or 8-bit signless integer values
bw_recurrent_to_input_weights tensor of any type values or none type
bw_recurrent_to_forget_weights tensor of 32-bit float or 8-bit signless integer values
bw_recurrent_to_cell_weights tensor of 32-bit float or 8-bit signless integer values
bw_recurrent_to_output_weights tensor of 32-bit float or 8-bit signless integer values
bw_cell_to_input_weights tensor of any type values or none type
bw_cell_to_forget_weights tensor of any type values or none type
bw_cell_to_output_weights tensor of any type values or none type
bw_input_gate_bias tensor of any type values or none type
bw_forget_gate_bias tensor of 32-bit float values
bw_cell_bias tensor of 32-bit float values
bw_output_gate_bias tensor of 32-bit float values
bw_projection_weights tensor of any type values or none type
bw_projection_bias tensor of any type values or none type
fw_input_activation_state stateful tensor
fw_input_cell_state stateful tensor
bw_input_activation_state stateful tensor
bw_input_cell_state stateful tensor
aux_input tensor of any type values or none type
fw_aux_input_to_input_weights tensor of any type values or none type
fw_aux_input_to_forget_weights tensor of any type values or none type
fw_aux_input_to_cell_weights tensor of any type values or none type
fw_aux_input_to_output_weights tensor of any type values or none type
bw_aux_input_to_input_weights tensor of any type values or none type
bw_aux_input_to_forget_weights tensor of any type values or none type
bw_aux_input_to_cell_weights tensor of any type values or none type
bw_aux_input_to_output_weights tensor of any type values or none type

Results:

Result Description
fw_output tensor of any type values
bw_output tensor of any type values

tfl.bitcast (TFL::BitcastOp)

Bitcast operator

Bitcasts a tensor from one type to another.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of any type values

Results:

Result Description
output tensor of any type values

tfl.bitwise_xor (TFL::BitwiseXorOp)

Bitwise Xor operator

Elementwise computes the bitwise XOR of lhs and rhs.

Traits: AlwaysSpeculatableImplTrait, Commutative, SameOperandsAndResultElementType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values
rhs tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values

Results:

Result Description
output tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values

tfl.broadcast_args (TFL::BroadcastArgsOp)

Return the shape of s0 op s1 with broadcast.

Given s0 and s1, tensors that represent shapes, compute r0, the broadcasted shape. s0, s1 and r0 are all integer vectors.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
s0 tensor of 32/64-bit signless integer values
s1 tensor of 32/64-bit signless integer values

Results:

Result Description
r0 tensor of 32/64-bit signless integer values

tfl.broadcast_to (TFL::BroadcastToOp)

Broadcast an array for a compatible shape.

Broadcasting is the process of making arrays to have compatible shapes for arithmetic operations. Two shapes are compatible if for each dimension pair they are either equal or one of them is one. When trying to broadcast a Tensor to a shape, it starts with the trailing dimensions, and works its way forward.

For example,

x = tf.constant([1, 2, 3]) y = tf.broadcast_to(x, [3, 3]) print(y) tf.Tensor( [[1 2 3] [1 2 3] [1 2 3]], shape=(3, 3), dtype=int32)

In the above example, the input Tensor with the shape of [1, 3] is broadcasted to output Tensor with shape of [3, 3].

When doing broadcasted operations such as multiplying a tensor by a scalar, broadcasting (usually) confers some time or space benefit, as the broadcasted tensor is never materialized.

However, broadcast_to does not carry with it any such benefits. The newly-created tensor takes the full memory of the broadcasted shape. (In a graph context, broadcast_to might be fused to subsequent operation and then be optimized away, however.)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 1-bit signless integer or 4-bit signless integer or 8-bit signless integer or QI8 type or 8-bit unsigned integer or 32-bit unsigned integer or QUI8 type or 16-bit signless integer or QI16 type or 64-bit signless integer or complex type with 32-bit float elements values
shape tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 1-bit signless integer or 4-bit signless integer or 8-bit signless integer or QI8 type or 8-bit unsigned integer or 32-bit unsigned integer or QUI8 type or 16-bit signless integer or QI16 type or 64-bit signless integer or complex type with 32-bit float elements values

tfl.bucketize (TFL::BucketizeOp)

Bucketizes 'input' based on 'boundaries'.

Example:

If the inputs are boundaries = [0, 10, 100] and input = [[-5, 10000][150, 10][5, 100]], then the output will be output = [[0, 3][3, 2][1, 3]].

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
boundaries::mlir::ArrayAttr32-bit float array attribute

Operands:

Operand Description
input tensor of 32-bit float or 64-bit float or 32-bit signless integer or 64-bit signless integer values

Results:

Result Description
output tensor of 32-bit signless integer values

tfl.call_once (TFL::CallOnceOp)

Invokes an initialization function

This operation invokes the given initialization function for the session initializer in tf saved model dialect.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
session_init_function::mlir::StringAttrstring attribute

tfl.cast (TFL::CastOp)

Cast operator

Casts input from input type to output type.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 16-bit float or 32-bit float or 64-bit float or 1-bit signless integer or 4-bit signless integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer or 64-bit signless integer or TFLite quint8 type or 8-bit unsigned integer or 8-bit signless integer or complex type with 32-bit float elements values

Results:

Result Description
output tensor of 16-bit float or 32-bit float or 64-bit float or 1-bit signless integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer or 64-bit signless integer or TFLite quint8 type or 8-bit unsigned integer or 8-bit signless integer or complex type with 32-bit float elements values

tfl.ceil (TFL::CeilOp)

Ceil operator

Returns element-wise ceil value of the input.

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.complex_abs (TFL::ComplexAbsOp)

Computes the complex absolute value of a tensor.

Given a tensor x of complex numbers, this operation returns a tensor of type float or double that is the absolute value of each element in x. All elements in x must be complex numbers of the form \(a + bj\). The absolute value is computed as \( \sqrt{a^2 + b^2}\).

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of complex type with 32-bit float elements or complex type with 64-bit float elements values

Results:

Result Description
output tensor of 32-bit float or 64-bit float values

tfl.concatenation (TFL::ConcatenationOp)

Concatenation operator

Concatenates tensors along one dimension

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
axis::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
values variadic of tensor of any type values

Results:

Result Description
output tensor of 32-bit float or 64-bit signless integer or 32-bit signless integer or 16-bit signless integer or 8-bit signless integer or QI8 type or QUI8 type or 8-bit unsigned integer or 32-bit unsigned integer or 1-bit signless integer values

tfl.control_node (TFL::ControlNodeOp)

The TFL.control_node operation wraps single-block operations in order to attach control edges.

This is used to wrap regions and attach control dependencies to them. Typically, this will happen in one of the last steps before emitting the flatbuffer model in order to enable optimizations that rely on a fixed order of operations (such as rematerialization.) The flatbuffer exporter will unwrap the wrapped region and annotate the generated model with metadata such that any runtime reorderings will respect the order given by the control dependencies.

Traits: HasParent<mlir::func::FuncOp>, RecursiveMemoryEffects, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Operands:

Operand Description
controlInputs variadic of control

Results:

Result Description
outputs variadic of tensor of any type values
control control

tfl.conv_2d (TFL::Conv2DOp)

Convolution operator

Performs convolution operation on inputs.

Inputs: inputs[0]: required: the input activation tensor inputs[1]: required: the filter weight tensor inputs[2]: optional: the bias tensor

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, quant::AccumulatorUniformScale<2, 0, 1>, quant::AffineOpCoefficient<0, 1>

Interfaces: AffineQuantizedOpInterface, ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TFL_SparseOp, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
dilation_h_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_w_factor::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_h::mlir::IntegerAttr32-bit signless integer attribute
stride_w::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values
filter tensor of 32-bit float or QI4 type or QI8 type or QUI8 type values
bias tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values

tfl.conv_3d (TFL::Conv3DOp)

Convolution 3D operator

Performs convolution operation on 3D inputs. Inputs: inputs[0]: required: the input activation tensor inputs[1]: required: the filter weight tensor inputs[2]: optional: the bias tensor

Traits: AlwaysSpeculatableImplTrait, quant::AccumulatorUniformScale<2, 0, 1>

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
dilation_d_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_h_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_w_factor::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_d::mlir::IntegerAttr32-bit signless integer attribute
stride_h::mlir::IntegerAttr32-bit signless integer attribute
stride_w::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
input tensor of 32-bit float values
filter tensor of 32-bit float values
bias tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float values

tfl.conv_3d_transpose (TFL::Conv3DTransposeOp)

Transposed Convolution 3D operator

Performs transposed convolution operation on 3D inputs. Inputs: inputs[0]: required: the shape of output tensor inputs[1]: required: the filter weight tensor inputs[2]: required: the input activation tensor inputs[3]: optional: the bias tensor

Traits: AlwaysSpeculatableImplTrait, quant::AccumulatorUniformScale<2, 0, 1>

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
dilation_d_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_h_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_w_factor::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_d::mlir::IntegerAttr32-bit signless integer attribute
stride_h::mlir::IntegerAttr32-bit signless integer attribute
stride_w::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
output_shape tensor of 32-bit signless integer values
filter tensor of 32-bit float values
input tensor of 32-bit float values
bias tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float values

tfl.cos (TFL::CosOp)

Cosine operator

Computes element-wise Cosine of input

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.cumsum (TFL::CumsumOp)

Cumsum operator

Compute the cumulative sum of the tensor x along axis.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
exclusive::mlir::BoolAttrbool attribute
reverse::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer values
axis tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer values

tfl.custom (TFL::CustomOp)

Custom op

A generic op for any TFLite custom operation.

input: A list of inputs in the original op. custom_code: A string used to identify which exactly this op is, which corresponds to operator_codes.custom_code in the flatbuffer. custom_option: a holder to save the op attributes in bytes fashion. output: A list of outputs in the original op.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
custom_code::mlir::StringAttrstring attribute
custom_option::mlir::TFL::ConstBytesAttrA string attribute representation of compiled bytes

Operands:

Operand Description
input variadic of tensor of any type values or none type

Results:

Result Description
output variadic of tensor of any type values

tfl.custom_tf (TFL::CustomTfOp)

Wrapper Op for TF custom ops.

A wrapper op around any Custom TF op. These includes ops defined using custom_opdefs or linked which are not defined in TF dialect. This Op just wraps the custom op inside a region. Note #1, this Op will not include TF Lite custom ops defined using CustomOp. Note #2, this op is just internal representation inside the converter and are not exposed/exported when the model is exported to Flatbuffer.

Traits: IsolatedFromAbove, RecursiveMemoryEffects, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: InferTypeOpInterface, TflRuntimeVerifyOpInterface

Operands:

Operand Description
input variadic of tensor of any type values or none type

Results:

Result Description
output variadic of tensor of any type values

tfl.densify (TFL::DensifyOp)

Densify operator

Converts sparse tensor to dense format.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer values

tfl.depth_to_space (TFL::DepthToSpaceOp)

DepthToSpace operator

Rearranges data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. The attr block_size indicates the input block size and how the data is moved.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
block_size::mlir::IntegerAttr32-bit signless integer attribute whose value is positive

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or TFLite quint8 type or 8-bit unsigned integer or QI8 type or QUI8 type values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or TFLite quint8 type or 8-bit unsigned integer or QI8 type or QUI8 type values

tfl.depthwise_conv_2d (TFL::DepthwiseConv2DOp)

Depthwise-separable convolution operator

Performs convolution operation on inputs.

Inputs: inputs[0]: required: the input activation tensor inputs[1]: required: the filter weight tensor inputs[2]: optional: the bias tensor

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, quant::AccumulatorUniformScale<2, 0, 1>, quant::AffineOpCoefficient<3, 1>

Interfaces: AffineQuantizedOpInterface, ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TFL_SparseOp, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
dilation_h_factor::mlir::IntegerAttr32-bit signless integer attribute
dilation_w_factor::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_h::mlir::IntegerAttr32-bit signless integer attribute
stride_w::mlir::IntegerAttr32-bit signless integer attribute
depth_multiplier::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values
filter tensor of 32-bit float or QI4 type or QI8 type or QUI8 type values
bias tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values

tfl.dequantize (TFL::DequantizeOp)

Dequantize operator

Converts quantized array of integers to floating-points according to the quantization parameters.

Interfaces: NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of QI4 type or QI8 type or QUI8 type or QI16 type or 16-bit float values

Results:

Result Description
output tensor of 32-bit float values

tfl.dilate (TFL::DilateOp)

Dilation operator

Extends a tensor by adding new elements between the existing ones. Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or 16-bit unsigned integer or 32-bit unsigned integer or 64-bit unsigned integer or 32-bit float or 64-bit float values
dilations tensor of 32-bit signless integer values
padding_value 0D tensor of any type values

Results:

Result Description
output tensor of 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or 16-bit unsigned integer or 32-bit unsigned integer or 64-bit unsigned integer or 32-bit float or 64-bit float values

tfl.div (TFL::DivOp)

Division operator

Element-wise division operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or QUI8 type values
rhs tensor of 32-bit float or 32-bit signless integer or QUI8 type values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or QUI8 type values

tfl.dynamic_update_slice (TFL::DynamicUpdateSliceOp)

DynamicUpdateSlice.

DynamicUpdateSlice op that have the same semantics with XLA DynamicUpdateSlice. Generates a result which is the value of the input array operand, with a slice update overwritten at start_indices.

See https://www.tensorflow.org/xla/operation_semantics#dynamicupdateslice

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
operand tensor of 1-bit signless integer or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values
update tensor of 1-bit signless integer or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values
start_indices tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer or 8-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values

tfl.elu (TFL::EluOp)

Exponential Linear Unit operator

Computes the exponential linear f(x) -> exp(x) - 1 for x < 0, x for x >= 0. element-wise.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or 8-bit signless integer values

Results:

Result Description
y tensor of 32-bit float or 8-bit signless integer values

tfl.embedding_lookup (TFL::EmbeddingLookupOp)

Embedding lookup operator

Looks up ids in a list of embedding tensors.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lookup tensor of 32-bit signless integer values
value tensor of 32-bit float or 8-bit signless integer or 8-bit unsigned integer values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 8-bit unsigned integer values

tfl.equal (TFL::EqualOp)

Equal operator

Returns the truth element of x == y element-wise

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 1-bit signless integer or 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or 8-bit unsigned integer or TFLite string type values
y tensor of 1-bit signless integer or 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or 8-bit unsigned integer or TFLite string type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.exp (TFL::ExpOp)

Natural exponentiation operator

Performs element-wise natural exponentiation operation on input.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QI8 type or QI16 type values

Results:

Result Description
y tensor of 32-bit float or QI8 type or QI16 type values

tfl.expand_dims (TFL::ExpandDimsOp)

Inserts a dimension of 1 into a tensor's shape.

Given a tensor input, this operation inserts a dimension of 1 at the dimension index axis of input's shape. The dimension index axis starts at zero; if you specify a negative number for axis it is counted backward from the end.

This operation is useful if you want to add a batch dimension to a single element. For example, if you have a single image of shape [height, width, channels], you can make it a batch of 1 image with expand_dims(image, 0), which will make the shape [1, height, width, channels].

Other examples:

# 't' is a tensor of shape [2]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]

# 't2' is a tensor of shape [2, 3, 5]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]

This operation requires that:

-1-input.dims() <= dim <= input.dims()

This operation is related to squeeze(), which removes dimensions of size 1.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of any type values
dim tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of any type values

tfl.external_const (TFL::ExternalConstOp)

External const op.

External const op holds a buffer_index which points to a constant in the flatbuffer.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
buffer_index::mlir::IntegerAttr32-bit signless integer attribute

Results:

Result Description
output tensor of any type values

tfl.fake_quant (TFL::FakeQuantOp)

FakeQuant operator

Fake-quantize the 'inputs' tensor of type float via float scalars min and max to 'outputs' tensor of same shape as inputs.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
min::mlir::FloatAttr32-bit float attribute
max::mlir::FloatAttr32-bit float attribute
num_bits::mlir::IntegerAttr32-bit signless integer attribute whose minimum value is 2 whose maximum value is 16
narrow_range::mlir::BoolAttrbool attribute whose value is false

Operands:

Operand Description
input tensor of 32-bit float values

Results:

Result Description
output tensor of 32-bit float values

tfl.fill (TFL::FillOp)

Fill the tensor with given value.

Fill the tensor with given value.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
dims tensor of 32/64-bit signless integer values
input tensor of 32-bit float or 16-bit float or 32-bit signless integer or 64-bit signless integer or 1-bit signless integer or QI8 type or QI16 type or TFLite string type values

Results:

Result Description
result tensor of 32-bit float or 16-bit float or 32-bit signless integer or 64-bit signless integer or 1-bit signless integer or QI8 type or QI16 type or TFLite string type values

tfl.floor (TFL::FloorOp)

Floor operator

Returns element-wise floor value of the input.

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.floor_div (TFL::FloorDivOp)

Floor div operator

Element-wise floor div operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer values
rhs tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer values

tfl.floor_mod (TFL::FloorModOp)

Division reminder

Element-wise division reminder operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values
rhs tensor of 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values

Results:

Result Description
output tensor of 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit float values

tfl.fully_connected (TFL::FullyConnectedOp)

Fully connected op

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, quant::AccumulatorUniformScale<2, 0, 1>, quant::AffineOpCoefficient<0, 1>

Interfaces: AffineQuantizedOpInterface, ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TFL_SparseOp, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
weights_format::mlir::StringAttrstring attribute whose value is DEFAULT, or SHUFFLED4x16INT8
keep_num_dims::mlir::BoolAttrbool attribute
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type or QUI16 type values
filter tensor of 32-bit float or QI4 type or QI8 type or QUI8 type or QI16 type values
bias tensor of any type values or none type

Results:

Result Description
output variadic of tensor of any type values

tfl.gather (TFL::GatherOp)

Gather operator

Gather slices from params axis axis according to indices.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
axis::mlir::IntegerAttr32-bit signless integer attribute
batch_dims::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
params tensor of 32-bit float or 1-bit signless integer or 4-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or TFLite string type or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values
indices tensor of 16-bit signless integer or 32-bit signless integer or 64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 1-bit signless integer or 4-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or TFLite string type or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values

tfl.gather_nd (TFL::GatherNdOp)

_Gathernd operator

Gather slices from params into a Tensor with shape specified by indices.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
params tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 64-bit signless integer or 32-bit signless integer or 8-bit unsigned integer or QI8 type or TFLite string type values
indices tensor of 16-bit signless integer or 32-bit signless integer or 64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 64-bit signless integer or 32-bit signless integer or 8-bit unsigned integer or QI8 type or TFLite string type values

tfl.gelu (TFL::GeluOp)

GELU activation function.

Computes GELU activation function element-wise.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
approximate::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type values

tfl.greater (TFL::GreaterOp)

Greater operator

Element-wise greater operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type values
rhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.greater_equal (TFL::GreaterEqualOp)

_Greaterequal operator

Element-wise greater_equal operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type values
rhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.hard_swish (TFL::HardSwishOp)

Hardswish activation function.

Computes hard-swish activation function f(x) -> (x * relu6(x+3))/6 element-wise.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or QUI8 type or QI8 type values

Results:

Result Description
output tensor of 32-bit float or QUI8 type or QI8 type values

tfl.hashtable (TFL::HashtableOp)

Creates a non-initialized hash table.

This op creates a hash table, specifying the type of its keys and values. Before using the table you will have to initialize it. After initialization the table will be immutable.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
table_id::mlir::IntegerAttr32-bit signless integer attribute
key_dtype::mlir::TypeAttrany type attribute
value_dtype::mlir::TypeAttrany type attribute

Results:

Result Description
out tensor of resource values

tfl.hashtable_find (TFL::HashtableFindOp)

Looks up keys in a table, outputs the corresponding values.

The tensor keys must of the same type as the keys of the table. The output values is of the type of the table values.

The scalar default_value is the value output for keys not present in the table. It must also be of the same type as the table values.

Interfaces: TflRuntimeVerifyOpInterface

Operands:

Operand Description
hash_table tensor of resource values
keys tensor of 32-bit signless integer or TFLite string type or 64-bit signless integer values
default_value tensor of 32-bit float or 32-bit signless integer or TFLite string type or 64-bit signless integer values

Results:

Result Description
out tensor of 32-bit float or 32-bit signless integer or TFLite string type or 64-bit signless integer values

tfl.hashtable_import (TFL::HashtableImportOp)

Replaces the contents of the table with the specified keys and values.

The tensor keys must be of the same type as the keys of the table. The tensor values must be of the type of the table values.

Interfaces: TflRuntimeVerifyOpInterface

Operands:

Operand Description
hash_table tensor of resource values
keys tensor of 32-bit signless integer or TFLite string type or 64-bit signless integer values
values tensor of 32-bit float or 32-bit signless integer or TFLite string type or 64-bit signless integer values

tfl.hashtable_size (TFL::HashtableSizeOp)

Computes the number of elements in the given table.

Interfaces: TflRuntimeVerifyOpInterface

Operands:

Operand Description
hash_table tensor of resource values

Results:

Result Description
out tensor of 64-bit signless integer values

tfl.if (TFL::IfOp)

If-then-else operation

The tfl.if operation represents an if-then-else construct for conditionally executing two regions of code. The operand to an if operation is a boolean value. For example:

tfl.if %b  {
  ...
} else {
  ...
}

tfl.if may also return results that are defined in its regions. The values defined are determined by which execution path is taken.

Example:

%x, %y = tfl.if %b -> (tensor<f32>, tensor<f32>) {
  %x_true = ...
  %y_true = ...
  tfl.yield %x_true, %y_true : tensor<f32>, tensor<f32>
} else {
  %x_false = ...
  %y_false = ...
  tfl.yield %x_false, %y_false : tensor<f32>, tensor<f32>
}

tfl.if regions are always terminated with "tfl.yield". If "tfl.if" defines no values, the "tfl.yield" can be left out, and will be inserted implicitly. Otherwise, it must be explicit. Also, if "tfl.if" defines one or more values, the 'else' block cannot be omitted.

Example:

tfl.if %b  {
  ...
}

Traits: NoRegionArguments, RecursiveMemoryEffects, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: RegionBranchOpInterface, TflRuntimeVerifyOpInterface

Operands:

Operand Description
cond tensor of 1-bit signless integer values

Results:

Result Description
results variadic of tensor of any type values

tfl.imag (TFL::ImagOp)

Returns the imaginary part of a complex number.

Given a tensor input of complex numbers, this operation returns a tensor of type float that is the imaginary part of each element in input. All elements in input must be complex numbers of the form \(a + bj\), where a is the real part and b is the imaginary part returned by this operation.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of complex type with 32-bit float elements or complex type with 64-bit float elements values

Results:

Result Description
output tensor of 32-bit float or 64-bit float values

tfl.l2_normalization (TFL::L2NormalizationOp)

L2 Normalize Operator

L2Normalization Op

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, FixedOutputRangeInterface, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
input tensor of 32-bit float or QUI8 type or QI8 type or QUI16 type or QI16 type or 8-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or QUI8 type or QI8 type or QUI16 type or QI16 type or 8-bit signless integer values

tfl.leaky_relu (TFL::LeakyReluOp)

Leaky Relu operator

Element-wise Leaky ReLU operator x -> x >= 0 ? x : (alpha * x)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
alpha::mlir::FloatAttr32-bit float attribute

Operands:

Operand Description
input tensor of 32-bit float or QUI8 type or QI8 type or TFLite quint8 type or QI16 type values

Results:

Result Description
output tensor of 32-bit float or QUI8 type or QI8 type or TFLite quint8 type or QI16 type values

tfl.less (TFL::LessOp)

Less operator

Element-wise less operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type values
rhs tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.less_equal (TFL::LessEqualOp)

_Lessequal operator

Element-wise less_equal operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type values
rhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.local_response_normalization (TFL::LocalResponseNormalizationOp)

Local Response Normalization.

The 4-D input tensor is treated as a 3-D array of 1-D vectors (along the last dimension), and each vector is normalized independently. Within a given vector, each component is divided by the weighted, squared sum of inputs within depth_radius. In detail,

sqr_sum[a, b, c, d] =
    sum(input[a, b, c, d - depth_radius : d + depth_radius + 1] ** 2)
output = input / (bias + alpha * sqr_sum) ** beta

For details, see Krizhevsky et al., ImageNet classification with deep convolutional neural networks (NIPS 2012).

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
radius::mlir::IntegerAttr32-bit signless integer attribute
bias::mlir::FloatAttr32-bit float attribute
alpha::mlir::FloatAttr32-bit float attribute
beta::mlir::FloatAttr32-bit float attribute

Operands:

Operand Description
input tensor of 32-bit float values

Results:

Result Description
output tensor of 32-bit float values

tfl.log (TFL::LogOp)

Natural logarithm operator

Performs element-wise natural logarithm operation on input.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QI8 type values

Results:

Result Description
y tensor of 32-bit float or QI8 type values

tfl.log_softmax (TFL::LogSoftmaxOp)

Log softmax operator

Computes element-wise log softmax activations with the following formula

input - log(reduce_sum(exp(input), dim))

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, FixedOutputRangeInterface, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or QUI8 type or QI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or QUI8 type or QI8 type or TFLite quint8 type values

tfl.logical_and (TFL::LogicalAndOp)

Logical AND operator

Element-wise logical AND operation.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 1-bit signless integer values
rhs tensor of 1-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.logical_not (TFL::LogicalNotOp)

Logical NOT operator

Element-wise logical NOT operation.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 1-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.logical_or (TFL::LogicalOrOp)

Logical OR operator

Element-wise logical OR operation.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 1-bit signless integer values
rhs tensor of 1-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.logistic (TFL::LogisticOp)

Logistic operator

Computes element-wise Sigmoid of input

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, FixedOutputRangeInterface, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
y tensor of 32-bit float or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.lstm (TFL::LSTMOp)

The full lstm operator

Long short-term memory unit (LSTM) recurrent network layer. The default non-peephole implementation is based on: http://deeplearning.cs.cmu.edu/pdfs/Hochreiter97_lstm.pdf S. Hochreiter and J. Schmidhuber. 'Long Short-Term Memory'. Neural Computation, 9(8):1735-1780, 1997. The peephole implementation is based on: https://research.google.com/pubs/archive/43905.pdf Hasim Sak, Andrew Senior, and Francoise Beaufays. 'Long short-term memory recurrent neural network architectures for large scale acoustic modeling.' INTERSPEECH, 2014. The coupling of input and forget gate (CIFG) is based on: http://arxiv.org/pdf/1503.04069.pdf Greff et al. 'LSTM: A Search Space Odyssey' The layer normalization is based on: https://arxiv.org/pdf/1607.06450.pdf Ba et al. 'Layer Normalization'

Traits: QuantizableResult

Interfaces: DynamicRangeQuantizedOpInterface, TFL_StatefulOp, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
cell_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
proj_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
kernel_type::mlir::TFL::LSTMKernelTypeAttrlstm_kernel_type whose value is mlir::TFL::LSTMKernelType::FULL
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute
input_to_input_intermediate::mlir::TypeAttrany type attribute
input_to_forget_intermediate::mlir::TypeAttrany type attribute
input_to_cell_intermediate::mlir::TypeAttrany type attribute
input_to_output_intermediate::mlir::TypeAttrany type attribute
effective_hidden_scale_intermediate::mlir::TypeAttrany type attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QI16 type values
input_to_input_weights tensor of any type values or none type
input_to_forget_weights tensor of 32-bit float or QI8 type values
input_to_cell_weights tensor of 32-bit float or QI8 type values
input_to_output_weights tensor of 32-bit float or QI8 type values
recurrent_to_input_weights tensor of any type values or none type
recurrent_to_forget_weights tensor of 32-bit float or QI8 type values
recurrent_to_cell_weights tensor of 32-bit float or QI8 type values
recurrent_to_output_weights tensor of 32-bit float or QI8 type values
cell_to_input_weights tensor of any type values or none type
cell_to_forget_weights tensor of any type values or none type
cell_to_output_weights tensor of any type values or none type
input_gate_bias tensor of any type values or none type
forget_gate_bias tensor of 32-bit float or QI32 type values
cell_bias tensor of 32-bit float or QI32 type values
output_gate_bias tensor of 32-bit float or QI32 type values
projection_weights tensor of any type values or none type
projection_bias tensor of any type values or none type
input_activation_state stateful tensor
input_cell_state stateful tensor
input_layer_norm_coefficients tensor of any type values or none type
forget_layer_norm_coefficients tensor of any type values or none type
cell_layer_norm_coefficients tensor of any type values or none type
output_layer_norm_coefficients tensor of any type values or none type

Results:

Result Description
output tensor of any type values

tfl.matrix_diag (TFL::MatrixDiagOp)

Returns a tensor with the provided diagonal and everything else padded with zeros.

Given a diagonal, returns a tensor with the diagonal and everything else padded with zeros. Assume diagonal has k dimensions [I, J, K, ..., N], then the output is a tensor of rank k+1 with dimensions [I, J, K, ..., N, N] where: output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n].

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
diagonal tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QUI8 type or QI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QUI8 type or QI8 type or TFLite quint8 type values

tfl.matrix_set_diag (TFL::MatrixSetDiagOp)

Returns a batched matrix tensor with new batched diagonal values.

Given input and diagonal, this operation returns a tensor with the same shape and values as input, except for the main diagonal of the innermost matrices. These will be overwritten by the values in diagonal.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QI16 type or QUI8 type or TFLite quint8 type values
diagonal tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QI16 type or QUI8 type or TFLite quint8 type values

Results:

Result Description
result tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QI16 type or QUI8 type or TFLite quint8 type values

tfl.max_pool_2d (TFL::MaxPool2DOp)

Max Pool 2D op

Performs max pool 2D on input.

Inputs: inputs[0]: required: the input tensor

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_w::mlir::IntegerAttr32-bit signless integer attribute
stride_h::mlir::IntegerAttr32-bit signless integer attribute
filter_width::mlir::IntegerAttr32-bit signless integer attribute
filter_height::mlir::IntegerAttr32-bit signless integer attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
input tensor of 32-bit float or QUI8 type or QI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or QUI8 type or QI8 type or QI16 type or TFLite quint8 type values

tfl.maximum (TFL::MaximumOp)

Max operator

Element-wise max operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values
rhs tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
max tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values

tfl.mean (TFL::MeanOp)

Mean operator

Computes the mean of elements across dimensions of a tensor. Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or 8-bit unsigned integer or QI16 type values
axis tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or 8-bit unsigned integer or QI16 type values

tfl.minimum (TFL::MinimumOp)

Min operator

Element-wise min operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values
rhs tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
min tensor of 32-bit float or 32/64-bit signless integer or QI8 type or QUI8 type or QI16 type values

tfl.mirror_pad (TFL::MirrorPadOp)

MirrorPad Operator. Pads a tensor with mirrored values.

This operation pads a input with mirrored values according to the paddings you specify. paddings is an integer tensor with shape [n, 2], where n is the rank of input. For each dimension D of input, paddings[D, 0] indicates how many values to add before the contents of input in that dimension, and paddings[D, 1] indicates how many values to add after the contents of input in that dimension.

Both paddings[D, 0] and paddings[D, 1] must be no greater than input.dim_size(D) (or input.dim_size(D) - 1) if copy_border is true (if false, respectively).

The padded size of each dimension D of the output is:

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
mode::mlir::TFL::MirrorPaddingTypeAttrmirror_pad_enum

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values
pad tensor of 32-bit signless integer or 64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values

tfl.mul (TFL::MulOp)

Multiplication operator

Element-wise multiplication operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or 32-bit unsigned integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type or 16-bit signless integer or complex type with 32-bit float elements values
rhs tensor of 32-bit float or 32-bit signless integer or 32-bit unsigned integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type or 16-bit signless integer or complex type with 32-bit float elements values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 32-bit unsigned integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type or 16-bit signless integer or complex type with 32-bit float elements values

tfl.multinomial (TFL::MultinomialOp)

Draws samples from a categorical distribution.

The generated values will have a categorical distribution based on the logits or unnormalized log-probabilities provided for all classes.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
seed::mlir::IntegerAttr64-bit signless integer attribute
seed2::mlir::IntegerAttr64-bit signless integer attribute

Operands:

Operand Description
logits tensor of 32-bit float values
num_samples tensor of 32-bit signless integer values

Results:

Result Description
out tensor of 32-bit signless integer or 64-bit signless integer values

tfl.neg (TFL::NegOp)

Negation operator

Computes element-wise negation of input

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer values

Results:

Result Description
y tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer values

tfl.no_value (TFL::NoValueOp)

Constant representing no value.

No value constant op.

Traits: AlwaysSpeculatableImplTrait, ConstantLike

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
value::mlir::UnitAttrunit attribute

Results:

Result Description
none_val none type

tfl.non_max_suppression_v4 (TFL::NonMaxSuppressionV4Op)

Greedily selects a subset of bounding boxes in descending order of score,

pruning away boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. Bounding boxes are supplied as [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The output of this operation is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the tf.gather operation. For example: selected_indices = tf.image.non_max_suppression_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
boxes tensor of 32-bit float values
scores tensor of 32-bit float values
max_output_size tensor of 32-bit signless integer values
iou_threshold tensor of 32-bit float values
score_threshold tensor of 32-bit float values

Results:

Result Description
selected_indices tensor of 32-bit signless integer values
valid_outputs tensor of 32-bit signless integer values

tfl.non_max_suppression_v5 (TFL::NonMaxSuppressionV5Op)

Greedily selects a subset of bounding boxes in descending order of score,

pruning away boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than score_threshold are removed. Bounding boxes are supplied as [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm is agnostic to where the origin is in the coordinate system and more generally is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The output of this operation is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the tf.gather operation. For example: selected_indices = tf.image.non_max_suppression_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices) This op also supports a Soft-NMS (with Gaussian weighting) mode (c.f. Bodla et al, https://arxiv.org/abs/1704.04503) where boxes reduce the score of other overlapping boxes instead of directly causing them to be pruned. To enable this Soft-NMS mode, set the soft_nms_sigma parameter to be larger than 0.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
boxes tensor of 32-bit float values
scores tensor of 32-bit float values
max_output_size tensor of 32-bit signless integer values
iou_threshold tensor of 32-bit float values
score_threshold tensor of 32-bit float values
soft_nms_sigma tensor of 32-bit float values

Results:

Result Description
selected_indices tensor of 32-bit signless integer values
selected_scores tensor of 32-bit float values
valid_outputs tensor of 32-bit signless integer values

tfl.not_equal (TFL::NotEqualOp)

_Notequal operator

Element-wise not_equal operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, Commutative, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 1-bit signless integer or 32-bit float or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type or TFLite string type values
rhs tensor of 1-bit signless integer or 32-bit float or 32-bit signless integer or 64-bit signless integer or QUI8 type or QI8 type or TFLite quint8 type or TFLite string type values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.NumericVerify (TFL::NumericVerifyOp)

Verifies the numericals of the two operands

The NumericVerify op is a debugging op to verify the numericals of the two activations. It is a custom op in TFLite. If log_if_failed is true, the NumericVerify op calculates statistics on differences between float and quantized activations, output logs, set differences to the output tensors, and throws an error if errors above tolerance exist. If log_if_failed = false, then it doesn't care about errors.

Traits: QuantizableResult, SameOperandsShape

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
tolerance::mlir::FloatAttr32-bit float attribute
log_if_failed::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of QI8 type or QUI8 type or QI16 type or 16-bit float or TFLite quint8 type values
ref tensor of 32-bit float values

Results:

Result Description
output tensor of 32-bit float values

tfl.one_hot (TFL::OneHotOp)

OneHot operator

Returns a one-hot tensor.The locations represented by indices in indices take value on_value, while all other locations take value off_value.

If the input indices is rank N, the output will have rank N+1, The new axis is created at dimension axis (default: the new axis is appended at the end).

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
axis::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
indices tensor of 32-bit signless integer or 64-bit signless integer values
depth tensor of 32-bit signless integer values
on_value tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 1-bit signless integer or 8-bit signless integer or 8-bit unsigned integer values
off_value tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 1-bit signless integer or 8-bit signless integer or 8-bit unsigned integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 1-bit signless integer or 8-bit signless integer or 8-bit unsigned integer values

tfl.pack (TFL::PackOp)

Packs a list of tensors along a dimension into one tensor

Packs a list of values_count rank-R tensors into one rank-(R+1) tensor.

Packs the values_count tensors in values into a tensor with rank one higher than each tensor in values, by packing them along the axis dimension.

Given a list of tensors of shape (A, B, C);

if axis == 0 then the output tensor will have the shape (N, A, B, C). if axis == 1 then the output tensor will have the shape (A, N, B, C). Etc.

For example:

# 'x' is [1, 4]
# 'y' is [2, 5]
# 'z' is [3, 6]
pack([x, y, z]) => [[1, 4], [2, 5], [3, 6]]  # Pack along first dim.
pack([x, y, z], axis=1) => [[1, 2, 3], [4, 5, 6]]

This is the opposite of unpack.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
values_count::mlir::IntegerAttr32-bit signless integer attribute whose value is positive
axis::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
values variadic of tensor of any type values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.pad (TFL::PadOp)

Padding operator

This operation pads a input with zeros according to the paddings you specify. paddings is an integer tensor with shape [Dn, 2], where n is the rank of input. For each dimension D of input, paddings[D, 0] indicates how many zeros to add before the contents of input in that dimension, and paddings[D, 1] indicates how many zeros to add after the contents of input in that dimension.

The padded size of each dimension D of the output is:

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

For example:

# 't' is [[1, 1], [2, 2]]
# 'paddings' is [[1, 1], [2, 2]]
# rank of 't' is 2
pad(t, paddings) ==> [[0, 0, 0, 0, 0, 0]
                      [0, 0, 1, 1, 0, 0]
                      [0, 0, 2, 2, 0, 0]
                      [0, 0, 0, 0, 0, 0]]

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
padding tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.padv2 (TFL::PadV2Op)

Padding operator v2

This operation pads a input according to the paddings and constant_values you specify. paddings is an integer tensor with shape [Dn, 2], where n is the rank of input. For each dimension D of input, paddings[D, 0] indicates how many zeros to add before the contents of input in that dimension, and paddings[D, 1] indicates how many zeros to add after the contents of input in that dimension. constant_values is a scalar tensor of the same type as input that indicates the value to use for padding input.

The padded size of each dimension D of the output is:

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

For example:

# 't' is [[1, 1], [2, 2]]
# 'paddings' is [[1, 1], [2, 2]]
# rank of 't' is 2
pad(t, paddings) ==> [[0, 0, 0, 0, 0, 0]
                      [0, 0, 1, 1, 0, 0]
                      [0, 0, 2, 2, 0, 0]
                      [0, 0, 0, 0, 0, 0]]

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite quint8 type values
padding tensor of 32/64-bit signless integer values
constant_values tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite quint8 type values

tfl.poly_call (TFL::PolyCallOp)

Poly call

Have multiple function bodies for the same computation. This allows a program compiler/interpreter to choose one of the available options to execute the program based on which one is most suitable for the target backend.

input: A list of input tensors whose types are T. output: A list of output tensors whose types are T.

call: Multiple regions, each of which encapsulates the same semantic computation but in different forms.

Traits: SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: RegionBranchOpInterface

Operands:

Operand Description
input variadic of tensor of any type values

Results:

Result Description
output variadic of tensor of any type values

tfl.pow (TFL::PowOp)

Power operator

Element-wise power operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer values
rhs tensor of 32-bit float or 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.prelu (TFL::PReluOp)

Parameterized Relu operator

Parameterized Relu operator x -> x >= 0 ? x : (alpha * x) where alpha is a trainable tensor. input and alpha should be the same size as input or be broadcastable.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape, quant::AffineOpCoefficient<-1, 1>

Interfaces: AffineQuantizedOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or TFLite quint8 type values
alpha tensor of 32-bit float or QI8 type or QUI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or TFLite quint8 type values

tfl.pseudo_const (TFL::ConstOp)

Constant pseudo op.

Represents a constant value in TensorFlow Lite dialect. This is not an actual operation and it will be lowered to buffer instead.

The op is allowed to have all the same type of attributes as tf.Const does (e.g., opaque TF attributes are allowed).

Traits: AlwaysSpeculatableImplTrait, ConstantLike, FirstAttrDerivedResultType, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
value::mlir::ElementsAttrconstant vector/tensor attribute

Results:

Result Description
output tensor of any type values

tfl.pseudo_qconst (TFL::QConstOp)

Quantized constant pseudo op

Represents a quantized constant value in TensorFlow Lite dialect. This is not an actual operation and it will be lowered to buffer instead. The quantization parameters are stored as a type attribute in this constant.

Traits: AlwaysSpeculatableImplTrait, FirstAttrDerivedResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
qtype::mlir::TypeAttrTensor type attribute
value::mlir::ElementsAttrconstant vector/tensor attribute

Results:

Result Description
output tensor of QUI8 type or QI8 type or QI16 type or QUI16 type or TFLite quint8 type values

tfl.pseudo_sparse_const (TFL::SparseConstOp)

Sparse constant pseudo op.

Represents a sparse constant value in TensorFlow Lite dialect. This is not an actual operation and it will be lowered to buffer instead.

Traits: AlwaysSpeculatableImplTrait, FirstAttrDerivedResultType, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
value::mlir::ElementsAttrconstant vector/tensor attribute
s_param::mlir::TFL::SparsityParameterAttrSparsity parameter.
compressed_data::mlir::ElementsAttrconstant vector/tensor attribute

Results:

Result Description
output tensor of any type values

tfl.pseudo_sparse_qconst (TFL::SparseQConstOp)

Sparse quantized constant pseudo op

Represents a sparse quantized constant value in TensorFlow Lite dialect. This is not an actual operation and it will be lowered to buffer instead. The quantization parameters are stored as a type attribute in this constant.

Traits: AlwaysSpeculatableImplTrait, FirstAttrDerivedResultType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
qtype::mlir::TypeAttrTensor type attribute
value::mlir::ElementsAttrconstant vector/tensor attribute
s_param::mlir::TFL::SparsityParameterAttrSparsity parameter.
compressed_data::mlir::ElementsAttrconstant vector/tensor attribute

Results:

Result Description
output tensor of QUI8 type or QI8 type or QI16 type or QUI16 type or TFLite quint8 type values

tfl.quantize (TFL::QuantizeOp)

Quantize operator

Converts floating point tensors to quantized integer tensors according to the quantization parameters defined in the type attribute.

Traits: FirstAttrDerivedResultType, SameOperandsAndResultShape

Interfaces: NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
qtype::mlir::TypeAttrTensor type attribute

Operands:

Operand Description
input tensor of 32-bit float or QI4 type or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
output tensor of QI4 type or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.random_standard_normal (TFL::RandomStandardNormalOp)

Outputs random values from a normal distribution.

The generated values will have mean 0 and standard deviation 1.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
seed::mlir::IntegerAttr64-bit signless integer attribute
seed2::mlir::IntegerAttr64-bit signless integer attribute

Operands:

Operand Description
shape tensor of 32-bit signless integer values

Results:

Result Description
out tensor of 32-bit float values

tfl.random_uniform (TFL::RandomUniformOp)

Outputs random values from a uniform distribution.

The generated values follow a uniform distribution in the range [0, 1). The lower bound 0 is included in the range, while the upper bound 1 is excluded.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
seed::mlir::IntegerAttr64-bit signless integer attribute
seed2::mlir::IntegerAttr64-bit signless integer attribute

Operands:

Operand Description
shape tensor of 32-bit signless integer values

Results:

Result Description
out tensor of 32-bit float values

tfl.range (TFL::RangeOp)

Range operator

Returns a 1D tensor defined by a sequence from start to limit with a given delta.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
start tensor of 32-bit signless integer or 32-bit float or 64-bit signless integer values
limit tensor of 32-bit signless integer or 32-bit float or 64-bit signless integer values
delta tensor of 32-bit signless integer or 32-bit float or 64-bit signless integer values

Results:

Result Description
result tensor of 32-bit signless integer or 32-bit float or 64-bit signless integer values

tfl.rank (TFL::RankOp)

Rank operator.

Returns the rank of a tensor.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of any type values

Results:

Result Description
output tensor of any integer type

tfl.read_variable (TFL::ReadVariableOp)

Reads variable value.

Read variable data identified by 'resource_id'.

Interfaces: TflRuntimeVerifyOpInterface

Operands:

Operand Description
resource_id tensor of resource values

Results:

Result Description
result tensor of 32-bit float or 64-bit float or 1-bit signless integer or 8-bit unsigned integer or 8-bit signless integer or QI8 type or QUI8 type or 32-bit signless integer or 64-bit signless integer or QI16 type or complex type with 32-bit float elements or complex type with 64-bit float elements values

tfl.real (TFL::RealOp)

Returns the real part of a complex number.

Given a tensor input of complex numbers, this operation returns a tensor of type float that is the real part of each element in input. All elements in input must be complex numbers of the form \(a + bj\), where a is the real part returned by this operation and b is the imaginary part.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of complex type with 32-bit float elements or complex type with 64-bit float elements values

Results:

Result Description
output tensor of 32-bit float or 64-bit float values

tfl.reduce_all (TFL::ReduceAllOp)

Computes the "logical and" of elements across dimensions of a tensor.

Reduces input along the dimensions given in axis. Unless keep_dims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keep_dims is true, the reduced dimensions are retained with length 1.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 1-bit signless integer values
reduction_indices tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.reduce_any (TFL::ReduceAnyOp)

Computes the "logical or" of elements across dimensions of a tensor.

Reduces input along the dimensions given in axis. Unless keep_dims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keep_dims is true, the reduced dimensions are retained with length 1.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 1-bit signless integer values
reduction_indices tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 1-bit signless integer values

tfl.reduce_max (TFL::ReduceMaxOp)

Max-reduction operator

Computes the max reduction along the specified axes

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
axes tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.reduce_min (TFL::ReduceMinOp)

Min-reduction operator

Computes the min reduction along the specified axes

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
axes tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.reduce_prod (TFL::ReduceProdOp)

Prod-reduction operator

Computes the product along the specified axes

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
axes tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.relu (TFL::ReluOp)

Relu operator

Element-wise Relu operator x -> max(0, x)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QUI8 type or QI8 type or QI16 type values

Results:

Result Description
y tensor of 32-bit float or QUI8 type or QI8 type or QI16 type values

tfl.relu6 (TFL::Relu6Op)

Relu6 operator

Element-wise Relu6 operator x -> max(0, min(6, x))

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QUI8 type or QI8 type values

Results:

Result Description
y tensor of 32-bit float or QUI8 type or QI8 type values

tfl.relu_0_to_1 (TFL::Relu0To1Op)

Relu0To1 operator

Element-wise Relu0To1 operator x -> max(0, min(1, x))

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QUI8 type or QI8 type values

Results:

Result Description
y tensor of 32-bit float or QUI8 type or QI8 type values

tfl.relu_n1_to_1 (TFL::Relu1Op)

Relu1 operator

Element-wise Relu1 operator x -> max(-1, min(1, x))

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QUI8 type or QI8 type values

Results:

Result Description
y tensor of 32-bit float or QUI8 type or QI8 type values

tfl.reshape (TFL::ReshapeOp)

Reshape operator

Produces a tensor with the same values but different static shape defined by the output type.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of any type values
shape tensor of 32-bit signless integer values

Results:

Result Description
output tensor of any type values

tfl.resize_bilinear (TFL::ResizeBilinearOp)

ResizeBilinear Op

Resize images to size using bilinear interpolation.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
align_corners::mlir::BoolAttrbool attribute
half_pixel_centers::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or TFLite quint8 type or QUI8 type or QI8 type or QI16 type values
size tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or TFLite quint8 type or QUI8 type or QI8 type or QI16 type values

tfl.resize_nearest_neighbor (TFL::ResizeNearestNeighborOp)

ResizeNearestNeighbor Op

Resize images to size using nearest neighbor interpolation.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
align_corners::mlir::BoolAttrbool attribute
half_pixel_centers::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or TFLite quint8 type or QUI8 type or QI8 type or QI16 type values
size tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or TFLite quint8 type or QUI8 type or QI8 type or QI16 type values

tfl.reverse_sequence (TFL::ReverseSequenceOp)

Reverses variable length slices.

This op first slices input along the dimension batch_dim, and for each slice i, reverses the first seq_lengths[i] elements along the dimension seq_dim.

The elements of seq_lengths must obey seq_lengths[i] <= input.dims[seq_dim], and seq_lengths must be a vector of length input.dims[batch_dim].

The output slice i along dimension batch_dim is then given by input slice i, with the first seq_lengths[i] slices along dimension seq_dim reversed.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
seq_dim::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative
batch_dim::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI16 type or QUI8 type or TFLite quint8 type values
seq_lengths tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI16 type or QUI8 type or TFLite quint8 type values

tfl.reverse_v2 (TFL::ReverseV2Op)

ReverseV2 Operator

Reverses specific dimensions of a tensor.

Given a tensor, and a int32/int64 tensor axis representing the set of dimensions of tensor to reverse. This operation reverses each dimension i for which there exists j s.t. axis[j] == i.

Args: tensor: A Tensor. Must be one of the following types: uint8, int8, int16, int32, int64, float32, bool Up to 8-D.

axis: A Tensor. Must be one of the following types: int32, int64. with only 1 element which is the axis index. TODO: Add support for multiple elements.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 8-bit unsigned integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI16 type or QUI8 type or QI8 type or TFLite quint8 type or 1-bit signless integer values
axis tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 8-bit unsigned integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or QI16 type or QUI8 type or QI8 type or TFLite quint8 type or 1-bit signless integer values

tfl.rfft2d (TFL::RFFT2dOp)

2D real-valued fast Fourier transform.

Computes the 2-dimensional discrete Fourier transform of a real-valued signal over the inner-most 2 dimensions of input.

Since the DFT of a real signal is Hermitian-symmetric, RFFT2D only returns the fft_length / 2 + 1 unique components of the FFT for the inner-most dimension of output: the zero-frequency term, followed by the fft_length / 2 positive-frequency terms.

Along each axis RFFT2D is computed on, if fft_length is smaller than the corresponding dimension of input, the dimension is cropped. If it is larger, the dimension is padded with zeros.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float values
fft_length tensor of 32-bit signless integer values

Results:

Result Description
output tensor of complex type with 32-bit float elements values

tfl.right_shift (TFL::RightShiftOp)

Right Shift operator

Elementwise computes the bitwise right-shift of lhs by rhs.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultElementType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values
rhs tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values

Results:

Result Description
output tensor of 8-bit signless integer or 8-bit unsigned integer or 16-bit signless integer or 16-bit unsigned integer or 32-bit signless integer or 32-bit unsigned integer values

tfl.round (TFL::RoundOp)

Round operator

Rounds the values of a tensor to the nearest integer, element-wise.

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.rsqrt (TFL::RsqrtOp)

Reciprocal of square root operator

Computes element-wise reverse square root of input

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or QI8 type or QI16 type values

Results:

Result Description
y tensor of 32-bit float or QI8 type or QI16 type values

tfl.scatter_nd (TFL::ScatterNdOp)

_Scatternd operator

Scatter updates into a new tensor according to indices

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
indices tensor of 32-bit signless integer values
updates tensor of 32-bit float or 8-bit signless integer or 64-bit signless integer or 32-bit signless integer or 8-bit unsigned integer or 1-bit signless integer values
shape 1D tensor of any type values

Results:

Result Description
output tensor of 32-bit float or 8-bit signless integer or 64-bit signless integer or 32-bit signless integer or 8-bit unsigned integer or 1-bit signless integer values

tfl.segment_sum (TFL::SegmentSumOp)

SegmentSum operator

Computes the sum along segments of a tensor.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer values
segment_ids tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.select (TFL::SelectOp)

Select operator

Select values of 'x' if the corresponding value of 'condition' is true or the value of 'y' if false. There are valid condition input sizes:

  1. Either the same shape (in which case the select is elementwise), or
  2. condition must be Rank 1 and match over the first dimension.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
condition tensor of 1-bit signless integer values
x tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values
y tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.select_v2 (TFL::SelectV2Op)

SelectV2 operator

Select values of 'x' if the corresponding value of 'condition' is true or the value of 'y' if false. There are valid condition input sizes:

  1. Either the same shape (in which case the select is elementwise), or
  2. Broadcastable shapes between 'condition', 'x' and 'y'.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
condition tensor of 1-bit signless integer values
x tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values
y tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 32-bit unsigned integer or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.shape (TFL::ShapeOp)

Shape operator

Returns the shape of a tensor.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
out_type::mlir::Attributederived attribute

Operands:

Operand Description
input tensor of any type values

Results:

Result Description
output tensor of 32-bit signless integer or 64-bit signless integer values

tfl.sign (TFL::SignOp)

Sign operation

Returns NaN if x is NaN, 0 if x is 0, -1 if x < 0 and 1 if x > 0.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultElementType, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float or 64-bit float or 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 64-bit float or 32-bit signless integer values

tfl.sin (TFL::SinOp)

Sine operator

Computes element-wise Sine of input

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.slice (TFL::SliceOp)

Return a slice from 'input'.

The output tensor is a tensor with dimensions described by 'size' whose values are extracted from 'input' starting at the offsets in 'begin'.

begin is zero-based; size is one-based. If size[i] is -1, all remaining elements in dimension i are included in the slice. In other words, this is equivalent to setting: size[i] = input.dim_size(i) - begin[i]

Requirements: 0 <= begin[i] <= begin[i] + size[i] <= Di for i in [0, n)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer or 1-bit signless integer or TFLite string type or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
begin tensor of 32/64-bit signless integer values
size tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer or 1-bit signless integer or TFLite string type or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.softmax (TFL::SoftmaxOp)

Softmax operator

Computes element-wise softmax activations with the following formula

exp(input) / tf.reduce_sum(exp(input * beta), dim)

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, FixedOutputRangeInterface, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
beta::mlir::FloatAttr32-bit float attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.space_to_batch_nd (TFL::SpaceToBatchNdOp)

SpaceToBatchNd operator

This operation reshapes space dimensions into the "batch" dimension 0

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
block_shape tensor of 32-bit signless integer values
paddings tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.space_to_depth (TFL::SpaceToDepthOp)

SpaceToDepth operator

Rearranges blocks of spatial data, into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension. block_size indicates the input block size.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
block_size::mlir::IntegerAttr32-bit signless integer attribute whose value is positive

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type values

tfl.sparse_to_dense (TFL::SparseToDenseOp)

Converts a sparse representation into a dense tensor.

Builds an array dense with shape output_shape such that

# If sparse_indices is scalar
dense[i] = (i == sparse_indices ? sparse_values : default_value)

# If sparse_indices is a vector, then for each i
dense[sparse_indices[i]] = sparse_values[i]

# If sparse_indices is an n by d matrix, then for each i in [0, n)
dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = sparse_values[i]

All other values in dense are set to default_value. If sparse_values is a scalar, all sparse indices are set to this single value.

Indices should be sorted in lexicographic order, and indices must not contain any repeats. If validate_indices is true, these properties are checked during execution.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
sparse_indices tensor of 32/64-bit signless integer values
output_shape tensor of 32/64-bit signless integer values
sparse_values tensor of 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or QI8 type or 8-bit unsigned integer or QUI8 type or TFLite quint8 type or 32-bit float values
default_value tensor of 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or QI8 type or 8-bit unsigned integer or QUI8 type or TFLite quint8 type or 32-bit float values

Results:

Result Description
dense tensor of 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or QI8 type or 8-bit unsigned integer or QUI8 type or TFLite quint8 type or 32-bit float values

tfl.split (TFL::SplitOp)

Splits a tensor into num_split tensors along one dimension.

Splits the value tensor along split_dim into a number of sub-tensors with same shape as the original one, except for split_dim. Same as tf.Split.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
num_splits::mlir::IntegerAttr32-bit signless integer attribute whose value is positive

Operands:

Operand Description
split_dim tensor of 32-bit signless integer values
value tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
outputs variadic of tensor of any type values

tfl.split_v (TFL::SplitVOp)

Splits a tensor into num_split tensors along one dimension.

Splits the value tensor along split_dim into a number of sub-tensors with same shape as the original one, except for split_dim. The grouping of the resultant sub-tensors is decided by size-splits. Same as tf.SplitV.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
num_splits::mlir::IntegerAttr32-bit signless integer attribute whose value is positive

Operands:

Operand Description
value tensor of 32-bit float or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or QI16 type values
size_splits 1D tensor of 32-bit signless integer values
split_dim 0D tensor of 32-bit signless integer values

Results:

Result Description
outputs variadic of tensor of any type values

tfl.sqrt (TFL::SqrtOp)

Square root operator

Computes element-wise Square root of input

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.square (TFL::SquareOp)

Square operator

Computes element-wise Square of input

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
x tensor of 32-bit float values

Results:

Result Description
y tensor of 32-bit float values

tfl.squared_difference (TFL::SquaredDifferenceOp)

Squared difference operator

Element-wise squared difference operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or QI8 type values
rhs tensor of 32-bit float or 32-bit signless integer or QI8 type values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or QI8 type values

tfl.squeeze (TFL::SqueezeOp)

Removes dimensions of size 1 from the shape of a tensor.

Given a tensor input, this operation returns a tensor of the same type with all dimensions of size 1 removed. If you don't want to remove all size 1 dimensions, you can remove specific size 1 dimensions by specifying squeeze_dims.

For example:

# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3]

Or, to remove specific size 1 dimensions:

# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
squeeze_dims::mlir::ArrayAttr64-bit integer array attribute whose size is at most 8

Operands:

Operand Description
input tensor of any type values

Results:

Result Description
output tensor of any type values

tfl.strided_slice (TFL::StridedSliceOp)

StridedSlice Op

Return a strided slice from input.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
begin_mask::mlir::IntegerAttr32-bit signless integer attribute
end_mask::mlir::IntegerAttr32-bit signless integer attribute
ellipsis_mask::mlir::IntegerAttr32-bit signless integer attribute
new_axis_mask::mlir::IntegerAttr32-bit signless integer attribute
shrink_axis_mask::mlir::IntegerAttr32-bit signless integer attribute
offset::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer or QI8 type or QUI8 type or 1-bit signless integer or 16-bit signless integer or QI16 type or TFLite quint8 type or TFLite string type values
begin tensor of 32-bit signless integer values
end tensor of 32-bit signless integer values
strides tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer or QI8 type or QUI8 type or 1-bit signless integer or 16-bit signless integer or QI16 type or TFLite quint8 type or TFLite string type values

tfl.sub (TFL::SubOp)

Subtraction operator

Element-wise subtraction operation.

Traits: ::mlir::OpTrait::TFLRuntimeOpTrait, AlwaysSpeculatableImplTrait, QuantizableResult, ResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
lhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values
rhs tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or QI16 type values

tfl.sum (TFL::SumOp)

Sum operator

Computes the sum reduction along the specified axes

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
keep_dims::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values
axes tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer or 64-bit signless integer or QI8 type or QUI8 type or TFLite quint8 type or QI16 type values

tfl.svdf (TFL::SVDFOp)

Single value decomposition filter operator

The SVDF op is a decomposition of a densely connected op into low rank filters. For details: https://research.google.com/pubs/pub43813.html https://arxiv.org/abs/1812.02802

Traits: QuantizableResult, quant::AccumulatorUniformScale<3, 2, 4>

Interfaces: DynamicRangeQuantizedOpInterface, TFL_StatefulOp, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
rank::mlir::IntegerAttr32-bit signless integer attribute whose value is positive
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float or QI8 type values
feature_weights tensor of 32-bit float or QI8 type or QUI8 type values
time_weights tensor of 32-bit float or QI16 type values
input_gate_bias tensor of any type values or none type
activation_state stateful tensor

Results:

Result Description
output tensor of 32-bit float or QI8 type values

tfl.tanh (TFL::TanhOp)

Hyperbolic tangent operator

Computes element-wise Hyperbolic tangent of input

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, FixedOutputRangeInterface, NoMemoryEffect (MemoryEffectOpInterface), TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or QI16 type or TFLite quint8 type values

tfl.tile (TFL::TileOp)

Tile operator.

Constructs a tensor by tiling a given tensor.

This operation creates a new tensor by replicating input multiples times. The output tensor's i'th dimension has input.dims(i) * multiples[i] elements, and the values of input are replicated multiples[i] times along the 'i'th dimension. For example, tiling [a b c d] by [2] produces [a b c d a b c d].

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 1-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite string type values
multiples tensor of 32/64-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 1-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite string type values

tfl.topk_v2 (TFL::TopKV2Op)

TopK operator

Returns the top k largest element along each last dimensional slice of input and the indices of values within the last dimension of the input tensor.

Results are always sorted in the descending order.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type values
k tensor of 16-bit signless integer or 32-bit signless integer values

Results:

Result Description
values tensor of 32-bit float or 8-bit signless integer or 16-bit signless integer or 32-bit signless integer or 64-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type values
indices tensor of 16-bit signless integer or 32-bit signless integer values

tfl.transpose (TFL::TransposeOp)

Transpose operator

Returns the Transpose of x

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit signless integer or 32-bit float or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite quint8 type or 1-bit signless integer or 64-bit signless integer or QI16 type values
perm tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit signless integer or 32-bit float or 8-bit signless integer or 8-bit unsigned integer or QI8 type or QUI8 type or TFLite quint8 type or 1-bit signless integer or 64-bit signless integer or QI16 type values

tfl.transpose_conv (TFL::TransposeConvOp)

Transpose convolution operator

Performs transpose convolution operation on input.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, quant::AccumulatorUniformScale<3, 1, 2>, quant::AffineOpCoefficient<0, 1>

Interfaces: AffineQuantizedOpInterface, ConditionallySpeculatable, DynamicRangeQuantizedOpInterface, NoMemoryEffect (MemoryEffectOpInterface), TFL_SparseOp, TflArithmeticCountOpInterface, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
padding::mlir::StringAttrstring attribute whose value is SAME, or VALID
stride_h::mlir::IntegerAttr32-bit signless integer attribute whose value is positive
stride_w::mlir::IntegerAttr32-bit signless integer attribute whose value is positive
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT

Operands:

Operand Description
output_shape tensor of 32-bit signless integer values
weights tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values
input tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values
bias tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float or QI8 type or QUI8 type or QI16 type values

tfl.unidirectional_sequence_lstm (TFL::UnidirectionalSequenceLSTMOp)

Unidirectional sequence lstm operator

A recurrent neural network specified by an LSTM cell. This Op supports unrolling the input along the time or batch dimensions, and implements the following operation for each element in the sequence s = 1...sequence_length: outputs[s] = state = activation(LSTMOp(inputs[s]))

where LSTMOp is LSTM TF Lite Op and the “activation” is the function passed as the “fused_activation_function” argument (if not “NONE”).

Traits: QuantizableResult

Interfaces: DynamicRangeQuantizedOpInterface, InferTypeOpInterface, TFL_StatefulOp, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
cell_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
proj_clip::mlir::FloatAttr32-bit float attribute whose value is non-negative
time_major::mlir::BoolAttrbool attribute
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute
diagonal_recurrent_tensors::mlir::BoolAttrbool attribute
input_to_input_intermediate::mlir::TypeAttrany type attribute
input_to_forget_intermediate::mlir::TypeAttrany type attribute
input_to_cell_intermediate::mlir::TypeAttrany type attribute
input_to_output_intermediate::mlir::TypeAttrany type attribute
effective_hidden_scale_intermediate::mlir::TypeAttrany type attribute

Operands:

Operand Description
input tensor of 32-bit float values
input_to_input_weights tensor of any type values or none type
input_to_forget_weights tensor of 32-bit float or QI8 type values
input_to_cell_weights tensor of 32-bit float or QI8 type values
input_to_output_weights tensor of 32-bit float or QI8 type values
recurrent_to_input_weights tensor of any type values or none type
recurrent_to_forget_weights tensor of 32-bit float or QI8 type values
recurrent_to_cell_weights tensor of 32-bit float or QI8 type values
recurrent_to_output_weights tensor of 32-bit float or QI8 type values
cell_to_input_weights tensor of any type values or none type
cell_to_forget_weights tensor of any type values or none type
cell_to_output_weights tensor of any type values or none type
input_gate_bias tensor of any type values or none type
forget_gate_bias tensor of 32-bit float values
cell_bias tensor of 32-bit float values
output_gate_bias tensor of 32-bit float values
projection_weights tensor of any type values or none type
projection_bias tensor of any type values or none type
input_activation_state stateful tensor
input_cell_state stateful tensor
input_layer_norm_coefficients tensor of any type values or none type
forget_layer_norm_coefficients tensor of any type values or none type
cell_layer_norm_coefficients tensor of any type values or none type
output_layer_norm_coefficients tensor of any type values or none type

Results:

Result Description
output tensor of 32-bit float or QI8 type values

tfl.unidirectional_sequence_rnn (TFL::UnidirectionalSequenceRNNOp)

Unidirectional sequence rnn operator

A recurrent neural network specified by an RNN cell. This Op takes in input in a format {batch_size, seq_len, input_size} or {seq_len, batch_size, input_size} if it's time-majored.

It implements the following operation for each element in the sequence s = 1...sequence_length: outputs[s] = state = activation(RNNOp(inputs[s]))

where RNNOp is RNNOp TF Lite Op and the “activation” is the function passed as the “fused_activation_function” argument (if not “NONE”).

Traits: QuantizableResult

Interfaces: DynamicRangeQuantizedOpInterface, TFL_StatefulOp, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
time_major::mlir::BoolAttrbool attribute
fused_activation_function::mlir::StringAttrstring attribute whose value is NONE, or RELU, or RELU_N1_TO_1, or RELU6, or TANH, or SIGN_BIT
asymmetric_quantize_inputs::mlir::BoolAttrbool attribute

Operands:

Operand Description
input tensor of 32-bit float values
input_to_input_weights tensor of 32-bit float or QI8 type values
recurrent_to_input_weights tensor of 32-bit float or QI8 type values
input_gate_bias tensor of 32-bit float values
hidden_state stateful tensor

Results:

Result Description
output tensor of 32-bit float values

tfl.unique (TFL::UniqueOp)

Unique Op.

This operation returns a tensor output containing all of the unique elements of input sorted in the same order that they occur in input. This operation also returns a tensor idx the same size as x that contains the index of each value of input in the unique output output. In other words:

Traits: AlwaysSpeculatableImplTrait, QuantizableResult

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
idx_out_type::mlir::Attributederived attribute

Operands:

Operand Description
input tensor of 8-bit signless integer or QI8 type or 8-bit unsigned integer or QUI8 type or 16-bit signless integer or QI16 type or 32-bit signless integer or 64-bit signless integer or 32-bit float values

Results:

Result Description
output tensor of 8-bit signless integer or QI8 type or 8-bit unsigned integer or QUI8 type or 16-bit signless integer or QI16 type or 32-bit signless integer or 64-bit signless integer or 32-bit float values
idx tensor of 32/64-bit signless integer values

tfl.unpack (TFL::UnpackOp)

Unpacks a tensor along a dimension into multiple tensors

Unpacks a given dimension of a rank-R tensor into num rank-(R-1) tensors.

Unpacks num tensors from value by chipping it along the axis dimension. For example, given a tensor of shape (A, B, C, D);

If axis == 0 then the i'th tensor in output is the slice value[i, :, :, :] and each tensor in output will have shape (B, C, D). (Note that the dimension unpacked along is gone, unlike split).

If axis == 1 then the i'th tensor in output is the slice value[:, i, :, :] and each tensor in output will have shape (A, C, D). Etc.

This is the opposite of pack.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, SameOperandsAndResultElementType

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface), SameOperandsAndResultsScale, TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
num::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative
axis::mlir::IntegerAttr32-bit signless integer attribute

Operands:

Operand Description
input tensor of 32-bit float or 1-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit signless integer or QI8 type or QUI8 type or 16-bit signless integer or QI16 type values

Results:

Result Description
outputs variadic of tensor of any type values

tfl.unsorted_segment_max (TFL::UnsortedSegmentMaxOp)

UnsortedSegmentMax operator

Computes the maximum value along segments of a tensor such that output[i] = max(data[j....]) where segment_ids[j...] = i if the maximum is empty for a given segment ID i, it outputs the smallest possible value for the specific numeric type, output[i] = numeric_limits::lowest(). Note the values of segment_ids are always validated to be less than num_segments and an error is thrown for out-of-bound indices.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer values
segment_ids tensor of 32-bit signless integer values
num_segments tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.unsorted_segment_min (TFL::UnsortedSegmentMinOp)

UnsortedSegmentMin operator

Computes the minimum value along segments of a tensor such that output[i] = min(data[j....]) where segment_ids[j...] = i if the minimum is empty for a given segment ID i, it outputs the largest possible value for the specific numeric type, output[i] = numeric_limits::max(). Note the values of segment_ids are always validated to be less than num_segments and an error is thrown for out-of-bound indices.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer values
segment_ids tensor of 32-bit signless integer values
num_segments tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.unsorted_segment_prod (TFL::UnsortedSegmentProdOp)

UnsortedSegmentProd operator

Computes the product along segments of a tensor.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer values
segment_ids tensor of 32-bit signless integer values
num_segments tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.unsorted_segment_sum (TFL::UnsortedSegmentSumOp)

UnsortedSegmentSum operator

From a tensor segmentation, computes the output resulting from summing together elements mapped to the same segment_id. I.e. output[i] is equal to the tensor sum of all elements from the input tensor mapped to segment_id i. If no tensors are mapped to a particular included segment_id, the output at that indice will be a zero tensor with the appropriate shape. Note the values of segment_ids are always validated to be less than num_segments and an error is thrown for out-of-bound indices

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 32-bit float or 32-bit signless integer values
segment_ids tensor of 32-bit signless integer values
num_segments tensor of 32-bit signless integer values

Results:

Result Description
output tensor of 32-bit float or 32-bit signless integer values

tfl.var_handle (TFL::VarHandleOp)

Returns a handle to a variable resource from its name.

Returns a handle for a variable resource from its name. container: the container this variable is placed in. shared_name: the name by which this variable is referred to.

Interfaces: TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
container::mlir::StringAttrstring attribute
shared_name::mlir::StringAttrstring attribute

Results:

Result Description
resource_handle tensor of resource values

tfl.where (TFL::WhereOp)

Returns locations of nonzero / true values in a tensor.

This operation returns the coordinates of true elements in condition. The coordinates are returned in a 2-D tensor where the first dimension (rows) represents the number of true elements, and the second dimension (columns) represents the coordinates of the true elements. Keep in mind, the shape of the output tensor can vary depending on how many true values there are in condition. Indices are output in row-major order.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
condition tensor of 1-bit signless integer or 32-bit float or 32/64-bit signless integer or 8-bit signless integer or 8-bit unsigned integer or 32-bit unsigned integer values

Results:

Result Description
index tensor of 64-bit signless integer values

tfl.while (TFL::WhileOp)

While loop

output = input; while (cond(output)) { output = body(output) }

While loop where all values are passes through arguments with implicit capture.

input: A list of input tensors whose types are T. output: A list of output tensors whose types are T. cond: A region that takes 'input' and returns a boolean scalar tensor. body: A region that takes a list of tensors and returns another list of tensors. Both lists have the same types.

Traits: SingleBlockImplicitTerminator<YieldOp>, SingleBlock

Interfaces: LoopLikeOpInterface, TflRuntimeVerifyOpInterface

Attributes:

AttributeMLIR TypeDescription
is_stateless::mlir::BoolAttrbool attribute

Operands:

Operand Description
input variadic of tensor of any type values

Results:

Result Description
output variadic of tensor of any type values

tfl.yield (TFL::YieldOp)

Yield operation

The "yield" operation represents a return operation within the conditional and body of structured control flow (e.g., while), and a terminator for ControlNodeOp. The operation takes a variable number of operands and produces no results. The operand number and types must match the signature of the region that contains the operation.

Traits: AlwaysSpeculatableImplTrait, QuantizableResult, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
«unnamed» variadic of any type

tfl.zeros_like (TFL::ZerosLikeOp)

ZerosLike operator

Returns a tensor of zeros with the same shape and type as the input tensor.

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TflRuntimeVerifyOpInterface

Effects: MemoryEffects::Effect{}

Operands:

Operand Description
input tensor of 64-bit signless integer or 32-bit signless integer or 32-bit float values

Results:

Result Description
output tensor of 64-bit signless integer or 32-bit signless integer or 32-bit float values

Attributes

DimensionMetadataAttr

Dimension metadata.

Syntax:

#tfl.dimension_metadata<
  ::mlir::TFL::DimensionTypeAttr,   # format
  int32_t,   # dense_size
  ::llvm::ArrayRef<int32_t>,   # segments
  ::llvm::ArrayRef<int32_t>   # indices
>

Parameters:

Parameter C++ type Description
format ::mlir::TFL::DimensionTypeAttr dimension_type
dense_size int32_t
segments ::llvm::ArrayRef<int32_t>
indices ::llvm::ArrayRef<int32_t>

SparsityParameterAttr

Sparsity parameter.

Syntax:

#tfl.sparsity_parameter<
  ::llvm::ArrayRef<int32_t>,   # traversal_order
  ::llvm::ArrayRef<int32_t>,   # block_map
  ::llvm::ArrayRef<DimensionMetadataAttr>   # dim_metadata
>

Parameters:

Parameter C++ type Description
traversal_order ::llvm::ArrayRef<int32_t>
block_map ::llvm::ArrayRef<int32_t>
dim_metadata ::llvm::ArrayRef<DimensionMetadataAttr>

ConstBytesAttr

A string attribute representation of compiled bytes

Syntax Examples:

#tfl<const_bytes : "0xDEADBEEF">

Parameters:

Parameter C++ type Description
value ::llvm::StringRef

DimensionTypeAttr

dimension_type

Syntax:

#tfl.dimension_type_attr<
  ::mlir::TFL::DimensionType   # value
>

Enum cases:

  • DENSE (DENSE)
  • SPARSE_CSR (SPARSE_CSR) #### Parameters:
Parameter C++ type Description
value ::mlir::TFL::DimensionType an enum of type DimensionType

LSTMKernelTypeAttr

lstm_kernel_type

Syntax:

#tfl.lstm_kernel_type_attr<
  ::mlir::TFL::LSTMKernelType   # value
>

Enum cases:

  • FULL (FULL)
  • BASIC (BASIC) #### Parameters:
Parameter C++ type Description
value ::mlir::TFL::LSTMKernelType an enum of type LSTMKernelType

MirrorPaddingTypeAttr

mirror_pad_enum

Syntax:

#tfl.mirror_pad_attr<
  ::mlir::TFL::MirrorPaddingType   # value
>

Enum cases:

  • REFLECT (REFLECT)
  • SYMMETRIC (SYMMETRIC) #### Parameters:
Parameter C++ type Description
value ::mlir::TFL::MirrorPaddingType an enum of type MirrorPaddingType