Dialect 'tfl' definition

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

Operation definition

tfl.abs (TFL::AbsOp)

Absolute value operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.add_n (TFL::AddNOp)

add_n operator

Description:

Adds all input tensors element-wise.

Operands:

  1. inputs: tensor of any type values

Attributes:

Results:

  1. sum: tensor of any type values

tfl.add (TFL::AddOp)

Addition operator

Description:

Element-wise addition operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.arg_max (TFL::ArgMaxOp)

ArgMax operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. dim: tensor of any type values

Attributes:

Attribute MLIR Type Description
output_type Attribute derived attribute attribute

Results:

  1. output: tensor of any type values

tfl.arg_min (TFL::ArgMinOp)

ArgMin operator

Description:

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)

Operands:

  1. input: tensor of any type values
  2. dim: tensor of any type values

Attributes:

Attribute MLIR Type Description
output_type Attribute derived attribute attribute

Results:

  1. output: tensor of any type values

tfl.average_pool_2d (TFL::AveragePool2DOp)

Average_pool_2d operator

Description:

Performs average-pooling operation on input.

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
filter_height IntegerAttr 32-bit integer attribute attribute
filter_width IntegerAttr 32-bit integer attribute attribute
padding StringAttr padding enum attribute
stride_h IntegerAttr 32-bit integer attribute attribute
stride_w IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.basic_lstm (TFL::BasicLSTMOp)

The basic lstm operator

Description:

basic LSTM Cell Operator.

Operands:

  1. data_input: tensor of any type values
  2. prev_activ_input: tensor of any type values
  3. weights_input: tensor of any type values
  4. biases_input: tensor of any type values
  5. prev_state_input: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute
cell_clip FloatAttr 32-bit float attribute attribute
proj_clip FloatAttr 32-bit float attribute attribute
kernel_type StringAttr lstm kernel type enum case BASIC attribute

Results:

  1. activ_output: 2D tensor of any type values
  2. state_output: 2D tensor of any type values
  3. concat_temp: 2D tensor of any type values
  4. activ_temp: 2D tensor of any type values

tfl.batch_to_space_nd (TFL::BatchToSpaceNdOp)

BatchToSpaceNd operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. block_shape: tensor of any type values
  3. indices: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.cast (TFL::CastOp)

Cast operator

Description:

Casts input from input type to output type.

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.ceil (TFL::CeilOp)

Ceil operator

Description:

Returns element-wise ceil value of the input.

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.concatenation (TFL::ConcatenationOp)

Concatenation operator

Description:

Concatenates tensors along one dimension

Operands:

  1. values: tensor of any type values

Attributes:

Attribute MLIR Type Description
axis IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.pseudo_const (TFL::ConstOp)

Constant pseudo op.

Description:

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

Operands:

Attributes:

Attribute MLIR Type Description
value ElementsAttr constant vector/tensor attribute attribute

Results:

  1. output: tensor of any type values

tfl.conv_2d (TFL::Conv2DOp)

Convolution operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. filter: tensor of any type values
  3. bias: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
dilation_h_factor IntegerAttr 32-bit integer attribute attribute
dilation_w_factor IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute
padding StringAttr padding enum attribute
stride_h IntegerAttr 32-bit integer attribute attribute
stride_w IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.convolution_2d_transpose_bias (TFL::Convolution2DTransposeBiasOp)

Transpose convolution with bias operator

Description:

Performs transpose convolution operation on inputs, with the option of adding a bias. Note this is a custom op that is not supported in the standard runtime.

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

Operands:

  1. input: tensor of any type values
  2. filter: tensor of any type values
  3. bias: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
padding StringAttr padding enum attribute
stride_h IntegerAttr 32-bit integer attribute attribute
stride_w IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.cos (TFL::CosOp)

Cosine operator

Description:

Computes element-wise Cosine of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.densify (TFL::DensifyOp)

Densify operator

Description:

Converts sparse tensor to dense format.

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.depth_to_space (TFL::DepthToSpaceOp)

DepthToSpace operator

Description:

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.

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
block_size IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.depthwise_conv_2d (TFL::DepthwiseConv2DOp)

Depthwise-separable convolution operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. filter: tensor of any type values
  3. bias: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
dilation_h_factor IntegerAttr 32-bit integer attribute attribute
dilation_w_factor IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute
padding StringAttr padding enum attribute
stride_h IntegerAttr 32-bit integer attribute attribute
stride_w IntegerAttr 32-bit integer attribute attribute
depth_multiplier IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.dequantize (TFL::DequantizeOp)

Dequantize operator

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.div (TFL::DivOp)

Division operator

Description:

Element-wise division operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.elu (TFL::EluOp)

Exponential Linear Unit operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.embedding_lookup (TFL::EmbeddingLookupOp)

Embedding lookup operator

Description:

Looks up ids in a list of embedding tensors.

Operands:

  1. lookup: tensor of any type values
  2. value: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.equal (TFL::EqualOp)

Equal operator

Description:

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

Operands:

  1. x: tensor of any type values
  2. y: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.exp (TFL::ExpOp)

Natural exponentiation operator

Description:

Performs element-wise natural exponentiation operation on input.

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.expand_dims (TFL::ExpandDimsOp)

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

Description:

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.

Operands:

  1. input: tensor of any type values
  2. dim: tensor of any integer type

Attributes:

Results:

  1. output: tensor of any type values

tfl.external_const (TFL::ExternalConstOp)

External const op.

Description:

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

Operands:

Attributes:

Attribute MLIR Type Description
buffer_index IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.fake_quant (TFL::FakeQuantOp)

FakeQuant operator

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
min FloatAttr 32-bit float attribute attribute
max FloatAttr 32-bit float attribute attribute
num_bits IntegerAttr 32-bit integer attribute attribute
narrow_range BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.fill (TFL::FillOp)

Fill the tensor with given value.

Description:

Fill the tensor with given value.

Operands:

  1. dims: tensor of any type values
  2. value: tensor of any type values

Attributes:

Results:

  1. res: tensor of any type values

tfl.floor_div (TFL::FloorDivOp)

Floor div operator

Description:

Element-wise floor div operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.floor_mod (TFL::FloorModOp)

Division reminder

Description:

Element-wise division reminder operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.floor (TFL::FloorOp)

Floor operator

Description:

Returns element-wise floor value of the input.

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.fully_connected (TFL::FullyConnectedOp)

Fully connected op

Description:

Operands:

  1. input: tensor of any type values
  2. filter: tensor of any type values
  3. bias: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute
weights_format StringAttr fully connected options weights format attribute
keep_num_dims BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.gather_nd (TFL::GatherNdOp)

Gather_nd operator

Description:

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

Operands:

  1. params: tensor of any type values
  2. indices: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.gather (TFL::GatherOp)

Gather operator

Description:

Gather slices from params axis axis according to indices.

Operands:

  1. params: tensor of any type values
  2. indices: tensor of any type values

Attributes:

Attribute MLIR Type Description
axis IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.greater_equal (TFL::GreaterEqualOp)

Greater_equal operator

Description:

Element-wise greater_equal operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.greater (TFL::GreaterOp)

Greater operator

Description:

Element-wise greater operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.hard_swish (TFL::HardSwishOp)

Hardswish activation function.

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. out: tensor of any type values

tfl.l2_normalization (TFL::L2NormalizationOp)

L2 Normalize Operator

Description:

L2Normalization Op

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.lstm (TFL::LSTMOp)

The full lstm operator

Description:

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”

Operands:

  1. input: tensor of any type values
  2. input_to_input_weights: tensor of any type values or none type
  3. input_to_forget_weights: tensor of any type values
  4. input_to_cell_weights: tensor of any type values
  5. input_to_output_weights: tensor of any type values
  6. recurrent_to_input_weights: tensor of any type values or none type
  7. recurrent_to_forget_weights: tensor of any type values
  8. recurrent_to_cell_weights: tensor of any type values
  9. recurrent_to_output_weights: tensor of any type values
  10. cell_to_input_weights: tensor of any type values or none type
  11. cell_to_forget_weights: tensor of any type values or none type
  12. cell_to_output_weights: tensor of any type values or none type
  13. input_gate_bias: tensor of any type values or none type
  14. forget_gate_bias: tensor of any type values
  15. cell_bias: tensor of any type values
  16. output_gate_bias: tensor of any type values
  17. projection_weights: tensor of any type values or none type
  18. projection_bias: tensor of any type values or none type
  19. input_activation_state: stateful tensor
  20. input_cell_state: stateful tensor
  21. input_layer_norm_coefficients: tensor of any type values or none type
  22. forget_layer_norm_coefficients: tensor of any type values or none type
  23. cell_layer_norm_coefficients: tensor of any type values or none type
  24. output_layer_norm_coefficients: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute
cell_clip FloatAttr 32-bit float attribute attribute
proj_clip FloatAttr 32-bit float attribute attribute
kernel_type StringAttr lstm kernel type enum case FULL attribute

Results:

  1. output: tensor of any type values

tfl.leaky_relu (TFL::LeakyReluOp)

Leaky Relu operator

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
alpha FloatAttr 32-bit float attribute attribute

Results:

  1. output: tensor of any type values

tfl.less_equal (TFL::LessEqualOp)

Less_equal operator

Description:

Element-wise less_equal operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.less (TFL::LessOp)

Less operator

Description:

Element-wise less operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.local_response_normalization (TFL::LocalResponseNormalizationOp)

Local Response Normalization.

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
radius IntegerAttr 32-bit integer attribute attribute
bias FloatAttr 32-bit float attribute attribute
alpha FloatAttr 32-bit float attribute attribute
beta FloatAttr 32-bit float attribute attribute

Results:

  1. output: tensor of any type values

tfl.log (TFL::LogOp)

Natural logarithm operator

Description:

Performs element-wise natural logarithm operation on input.

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.log_softmax (TFL::LogSoftmaxOp)

Log softmax operator

Description:

Computes element-wise log softmax activations with the following formula

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

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.logical_and (TFL::LogicalAndOp)

Logical AND operator

Description:

Element-wise logical AND operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.logical_not (TFL::LogicalNotOp)

Logical NOT operator

Description:

Element-wise logical NOT operation.

Operands:

  1. lhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.logical_or (TFL::LogicalOrOp)

Logical OR operator

Description:

Element-wise logical OR operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.logistic (TFL::LogisticOp)

Logistic operator

Description:

Computes element-wise Sigmoid of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.matrix_diag (TFL::MatrixDiagOp)

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

Description:

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].

Operands:

  1. diagonal: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.matrix_set_diag (TFL::MatrixSetDiagOp)

Returns a batched matrix tensor with new batched diagonal values.

Description:

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.

Operands:

  1. input: tensor of 32-bit float or 32-bit integer or 64-bit integer or 8-bit integer or QI8 type or QI16 type or QUI8 type or TFLite uint8 type or TFLite quint8 type values
  2. diagonal: tensor of 32-bit float or 32-bit integer or 64-bit integer or 8-bit integer or QI8 type or QI16 type or QUI8 type or TFLite uint8 type or TFLite quint8 type values

Attributes:

Results:

  1. output: tensor of 32-bit float or 32-bit integer or 64-bit integer or 8-bit integer or QI8 type or QI16 type or QUI8 type or TFLite uint8 type or TFLite quint8 type values

tfl.max_pool_2d (TFL::MaxPool2DOp)

Max Pool 2D op

Description:

Performs max pool 2D on input.

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
padding StringAttr padding enum attribute
stride_w IntegerAttr 32-bit integer attribute attribute
stride_h IntegerAttr 32-bit integer attribute attribute
filter_width IntegerAttr 32-bit integer attribute attribute
filter_height IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.max_pooling_with_argmax_2d (TFL::MaxPoolingWithArgMax2DOp)

Max Pool 2D with argmax op

Description:

Performs max pooling on the input and outputs both max values and indices. Each index is a flatten index in a sub-array of "filter_w" x "filter_h" size Note this is a custom op that is not supported in the standard runtime.

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
padding StringAttr padding enum attribute
stride_w IntegerAttr 32-bit integer attribute attribute
stride_h IntegerAttr 32-bit integer attribute attribute
filter_w IntegerAttr 32-bit integer attribute attribute
filter_h IntegerAttr 32-bit integer attribute attribute

Results:

  1. value: tensor of any type values
  2. indices: tensor of any type values

tfl.max_unpooling_2d (TFL::MaxUnpooling2DOp)

Max Unpool 2D

Description:

Performs max unpool operation. To some extent this is the reverse operation of max pooling: the elements in the input activation tensor is stored into the position specified by the input indices. Note this is a custom op that is not supported in the standard runtime.

Inputs: inputs[0]: required: the input activation tensor inputs[1]: required: the input indices

Operands:

  1. input: tensor of any type values
  2. indices: tensor of any type values

Attributes:

Attribute MLIR Type Description
padding StringAttr padding enum attribute
stride_w IntegerAttr 32-bit integer attribute attribute
stride_h IntegerAttr 32-bit integer attribute attribute
filter_w IntegerAttr 32-bit integer attribute attribute
filter_h IntegerAttr 32-bit integer attribute attribute

Results:

  1. outputs: tensor of any type values

tfl.maximum (TFL::MaximumOp)

Max operator

Description:

Element-wise max operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. max: tensor of any type values

tfl.mean (TFL::MeanOp)

Mean operator

Description:

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.

Operands:

  1. input: tensor of any type values
  2. axis: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.minimum (TFL::MinimumOp)

Min operator

Description:

Element-wise min operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. min: tensor of any type values

tfl.mirror_pad (TFL::MirrorPadOp)

MirrorPad Operator. Pads a tensor with mirrored values.

Description:

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)

Operands:

  1. input: tensor of any type values
  2. pad: tensor of any type values

Attributes:

Attribute MLIR Type Description
mode StringAttr Mirror pad enum attribute

Results:

  1. output: tensor of any type values

tfl.mul (TFL::MulOp)

Multiplication operator

Description:

Element-wise multiplication operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.neg (TFL::NegOp)

Negation operator

Description:

Computes element-wise negation of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.non_max_suppression_v4 (TFL::NonMaxSuppressionV4Op)

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

Description:

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)

Operands:

  1. boxes: tensor of any type values
  2. scores: tensor of any type values
  3. max_output_size: tensor of any type values
  4. iou_threshold: tensor of any type values
  5. score_threshold: tensor of any type values

Attributes:

Results:

  1. selected_indices: tensor of any type values
  2. valid_outputs: tensor of any type values

tfl.non_max_suppression_v5 (TFL::NonMaxSuppressionV5Op)

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

Description:

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.

Operands:

  1. boxes: tensor of any type values
  2. scores: tensor of any type values
  3. max_output_size: tensor of any type values
  4. iou_threshold: tensor of any type values
  5. score_threshold: tensor of any type values
  6. soft_nms_sigma: tensor of any type values

Attributes:

Results:

  1. selected_indices: tensor of any type values
  2. selected_scores: tensor of any type values
  3. valid_outputs: tensor of any type values

tfl.not_equal (TFL::NotEqualOp)

Not_equal operator

Description:

Element-wise not_equal operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.NumericVerify (TFL::NumericVerifyOp)

Verifies the numericals of the two operands

Description:

The NumericVerify op is a debugging op to verify the numericals of the two activations. It is a custom op in TFLite.

Operands:

  1. input: tensor of any type values
  2. ref: tensor of any type values

Attributes:

Attribute MLIR Type Description
tolerance FloatAttr 32-bit float attribute attribute

Results:

tfl.one_hot (TFL::OneHotOp)

OneHot operator

Description:

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

Operands:

  1. indices: tensor of any type values
  2. depth: tensor of any type values
  3. on_value: tensor of any type values
  4. off_value: tensor of any type values

Attributes:

Attribute MLIR Type Description
axis IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.prelu (TFL::PReluOp)

Parameterized Relu operator

Description:

Parameterized Relu operator x -> x >= 0 ? x : (alpha * x) where alpha is a trainable tensor. alpha should have one less rank than the input as it doesn't have the batch dimension, and the other dimensions either should be the same size as input or size 1, where it is broadcasted in the second case.

Operands:

  1. input: tensor of any type values
  2. alpha: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.pack (TFL::PackOp)

Packs a list of tensors along a dimension into one tensor

Description:

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.

Operands:

  1. values: tensor of any type values

Attributes:

Attribute MLIR Type Description
values_count IntegerAttr 32-bit integer attribute attribute
axis IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.pad (TFL::PadOp)

Padding operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. padding: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.padv2 (TFL::PadV2Op)

Padding operator v2

Description:

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

Operands:

  1. input: tensor of any type values
  2. padding: tensor of any type values
  3. constant_values: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.pow (TFL::PowOp)

Power operator

Description:

Element-wise power operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.pseudo_qconst (TFL::QConstOp)

Quantized constant pseudo op

Description:

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.

Operands:

Attributes:

Attribute MLIR Type Description
qtype TypeAttr Tensor type attribute attribute
value ElementsAttr constant vector/tensor attribute attribute

Results:

  1. output: tensor of any type values

tfl.quantize (TFL::QuantizeOp)

Quantize operator

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
qtype TypeAttr Tensor type attribute attribute

Results:

  1. output: tensor of any type values

tfl.range (TFL::RangeOp)

Range operator

Description:

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

Operands:

  1. start: tensor of any type values
  2. limit: tensor of any type values
  3. delta: tensor of any type values

Attributes:

Results:

  1. result: tensor of any type values

tfl.rank (TFL::RankOp)

Rank operator.

Description:

Returns the rank of a tensor.

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any integer type

tfl.reduce_any (TFL::ReduceAnyOp)

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

Description:

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.

Operands:

  1. input: tensor of any type values
  2. reduction_indices: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.reduce_max (TFL::ReduceMaxOp)

Max-reduction operator

Description:

Computes the max reduction along the specified axes

Operands:

  1. input: tensor of any type values
  2. axes: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. «unnamed»: tensor of any type values

tfl.reduce_min (TFL::ReduceMinOp)

Min-reduction operator

Description:

Computes the min reduction along the specified axes

Operands:

  1. input: tensor of any type values
  2. axes: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. «unnamed»: tensor of any type values

tfl.reduce_prod (TFL::ReduceProdOp)

Prod-reduction operator

Description:

Computes the product along the specified axes

Operands:

  1. input: tensor of any type values
  2. axes: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. «unnamed»: tensor of any type values

tfl.relu_n1_to_1 (TFL::Relu1Op)

Relu1 operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.relu6 (TFL::Relu6Op)

Relu6 operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.relu (TFL::ReluOp)

Relu operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.reshape (TFL::ReshapeOp)

Reshape operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. shape: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.resize_bilinear (TFL::ResizeBilinearOp)

ResizeBilinear Op

Description:

Resize images to size using bilinear interpolation.

Operands:

  1. input: tensor of any type values
  2. size: tensor of any type values

Attributes:

Attribute MLIR Type Description
align_corners BoolAttr bool attribute attribute
half_pixel_centers BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.resize_nearest_neighbor (TFL::ResizeNearestNeighborOp)

ResizeNearestNeighbor Op

Description:

Resize images to size using nearest neighbor interpolation.

Operands:

  1. input: tensor of any type values
  2. size: tensor of any type values

Attributes:

Attribute MLIR Type Description
align_corners BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.reverse_sequence (TFL::ReverseSequenceOp)

Reverses variable length slices.

Description:

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.

Operands:

  1. input: tensor of any type values
  2. seq_lengths: tensor of any type values

Attributes:

Attribute MLIR Type Description
seq_dim IntegerAttr 32-bit integer attribute attribute
batch_dim IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.reverse_v2 (TFL::ReverseV2Op)

ReverseV2 Operator

Description:

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, 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.

Operands:

  1. input: tensor of any type values
  2. axis: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.round (TFL::RoundOp)

Round operator

Description:

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

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.rsqrt (TFL::RsqrtOp)

Reciprocal of square root operator

Description:

Computes element-wise reverse square root of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.svdf (TFL::SVDFOp)

Single value decomposition filter operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. feature_weights: tensor of any type values
  3. time_weights: tensor of any type values
  4. input_gate_bias: tensor of any type values or none type
  5. activation_state: stateful tensor

Attributes:

Attribute MLIR Type Description
rank IntegerAttr 32-bit integer attribute attribute
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.segment_sum (TFL::SegmentSumOp)

SegmentSum operator

Description:

Computes the sum along segments of a tensor.

Operands:

  1. data: tensor of any type values
  2. segment_ids: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.select (TFL::SelectOp)

Select operator

Description:

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.

Operands:

  1. condition: tensor of any type values
  2. x: tensor of any type values
  3. y: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.select_v2 (TFL::SelectV2Op)

SelectV2 operator

Description:

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'.

Operands:

  1. condition: tensor of any type values
  2. x: tensor of any type values
  3. y: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.shape (TFL::ShapeOp)

Shape operator

Description:

Returns the shape of a tensor.

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
out_type Attribute derived attribute attribute

Results:

  1. output: tensor of any type values

tfl.sin (TFL::SinOp)

Sine operator

Description:

Computes element-wise Sine of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.slice (TFL::SliceOp)

Return a slice from 'input'.

Description:

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)

Operands:

  1. input: tensor of any type values
  2. begin: tensor of any type values
  3. size: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.softmax (TFL::SoftmaxOp)

Softmax operator

Description:

Computes element-wise softmax activations with the following formula

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
beta FloatAttr 32-bit float attribute attribute

Results:

  1. output: tensor of any type values

tfl.space_to_batch_nd (TFL::SpaceToBatchNdOp)

SpaceToBatchNd operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. block_shape: tensor of any type values
  3. paddings: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.space_to_depth (TFL::SpaceToDepthOp)

SpaceToDepth operator

Description:

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.

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
block_size IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.pseudo_sparse_const (TFL::SparseConstOp)

Sparse constant pseudo op.

Description:

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

Operands:

Attributes:

Attribute MLIR Type Description
value ElementsAttr constant vector/tensor attribute attribute
s_param TFL::SparsityParameterAttr Sparsity parameter. attribute

Results:

  1. output: tensor of any type values

tfl.pseudo_sparse_qconst (TFL::SparseQConstOp)

Sparse quantized constant pseudo op

Description:

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.

Operands:

Attributes:

Attribute MLIR Type Description
qtype TypeAttr Tensor type attribute attribute
value ElementsAttr constant vector/tensor attribute attribute
s_param TFL::SparsityParameterAttr Sparsity parameter. attribute

Results:

  1. output: tensor of any type values

tfl.sparse_to_dense (TFL::SparseToDenseOp)

Converts a sparse representation into a dense tensor.

Description:

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.

Operands:

  1. sparse_indices: tensor of any type values
  2. output_shape: tensor of any type values
  3. sparse_values: tensor of any type values
  4. default_value: tensor of any type values

Attributes:

Results:

  1. dense: tensor of any type values

tfl.split (TFL::SplitOp)

Splits a tensor into num_split tensors along one dimension.

Description:

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.

Operands:

  1. split_dim: tensor of any type values
  2. value: tensor of any type values

Attributes:

Attribute MLIR Type Description
num_splits IntegerAttr positive 32-bit integer attribute attribute

Results:

  1. outputs: tensor of any type values

tfl.split_v (TFL::SplitVOp)

Splits a tensor into num_split tensors along one dimension.

Description:

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.

Operands:

  1. value: tensor of any type values
  2. size_splits: 1D tensor of 32-bit integer values
  3. split_dim: 0D tensor of 32-bit integer values

Attributes:

Attribute MLIR Type Description
num_splits IntegerAttr positive 32-bit integer attribute attribute

Results:

  1. outputs: tensor of any type values

tfl.sqrt (TFL::SqrtOp)

Square root operator

Description:

Computes element-wise Square root of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.square (TFL::SquareOp)

Square operator

Description:

Computes element-wise Square of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.squared_difference (TFL::SquaredDifferenceOp)

Squared difference operator

Description:

Element-wise squared difference operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.squeeze (TFL::SqueezeOp)

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

Description:

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 axis.

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]

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
squeeze_dims ArrayAttr 64-bit integer array attribute attribute

Results:

  1. output: tensor of any type values

tfl.strided_slice (TFL::StridedSliceOp)

StridedSlice Op

Description:

Return a strided slice from input.

Operands:

  1. input: tensor of any type values
  2. begin: tensor of any type values
  3. end: tensor of any type values
  4. strides: tensor of any type values

Attributes:

Attribute MLIR Type Description
begin_mask IntegerAttr 32-bit integer attribute attribute
end_mask IntegerAttr 32-bit integer attribute attribute
ellipsis_mask IntegerAttr 32-bit integer attribute attribute
new_axis_mask IntegerAttr 32-bit integer attribute attribute
shrink_axis_mask IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.sub (TFL::SubOp)

Subtraction operator

Description:

Element-wise subtraction operation.

Operands:

  1. lhs: tensor of any type values
  2. rhs: tensor of any type values

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.sum (TFL::SumOp)

Sum operator

Description:

Computes the sum reduction along the specified axes

Operands:

  1. input: tensor of any type values
  2. axes: tensor of any type values

Attributes:

Attribute MLIR Type Description
keep_dims BoolAttr bool attribute attribute

Results:

  1. «unnamed»: tensor of any type values

tfl.tanh (TFL::TanhOp)

Hyperbolic tangent operator

Description:

Computes element-wise Hyperbolic tangent of input

Operands:

  1. x: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.tile (TFL::TileOp)

Tile operator.

Description:

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].

Operands:

  1. input: tensor of any type values
  2. multiples: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values

tfl.topk_v2 (TFL::TopKV2Op)

TopK operator

Description:

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.

Operands:

  1. input: tensor of any type values
  2. k: tensor of any type values

Attributes:

Results:

  1. values: tensor of any type values
  2. indices: tensor of any type values

tfl.transpose_conv (TFL::TransposeConvOp)

Transpose convolution operator

Description:

Performs transpose convolution operation on input.

Operands:

  1. output_shape: 1D tensor of any type values
  2. weights: tensor of any type values
  3. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
padding StringAttr padding enum attribute
stride_h IntegerAttr 32-bit integer attribute attribute
stride_w IntegerAttr 32-bit integer attribute attribute

Results:

  1. output: tensor of any type values

tfl.transpose (TFL::TransposeOp)

Transpose operator

Description:

Returns the Transpose of x

Operands:

  1. x: tensor of any type values
  2. perm: tensor of any type values

Attributes:

Results:

  1. y: tensor of any type values

tfl.unidirectional_sequence_lstm (TFL::UnidirectionalSequenceLSTMOp)

Unidirectional sequence lstm operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. input_to_input_weights: tensor of any type values or none type
  3. input_to_forget_weights: tensor of any type values
  4. input_to_cell_weights: tensor of any type values
  5. input_to_output_weights: tensor of any type values
  6. recurrent_to_input_weights: tensor of any type values or none type
  7. recurrent_to_forget_weights: tensor of any type values
  8. recurrent_to_cell_weights: tensor of any type values
  9. recurrent_to_output_weights: tensor of any type values
  10. cell_to_input_weights: tensor of any type values or none type
  11. cell_to_forget_weights: tensor of any type values or none type
  12. cell_to_output_weights: tensor of any type values or none type
  13. input_gate_bias: tensor of any type values or none type
  14. forget_gate_bias: tensor of any type values
  15. cell_bias: tensor of any type values
  16. output_gate_bias: tensor of any type values
  17. projection_weights: tensor of any type values or none type
  18. projection_bias: tensor of any type values or none type
  19. input_activation_state: stateful tensor
  20. input_cell_state: stateful tensor
  21. input_layer_norm_coefficients: tensor of any type values or none type
  22. forget_layer_norm_coefficients: tensor of any type values or none type
  23. cell_layer_norm_coefficients: tensor of any type values or none type
  24. output_layer_norm_coefficients: tensor of any type values or none type

Attributes:

Attribute MLIR Type Description
fused_activation_function StringAttr fused activation enum attribute
cell_clip FloatAttr 32-bit float attribute attribute
proj_clip FloatAttr 32-bit float attribute attribute
time_major BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.unidirectional_sequence_rnn (TFL::UnidirectionalSequenceRNNOp)

Unidirectional sequence rnn operator

Description:

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

Operands:

  1. input: tensor of any type values
  2. input_to_input_weights: tensor of any type values
  3. recurrent_to_input_weights: tensor of any type values
  4. input_gate_bias: tensor of any type values
  5. hidden_state: stateful tensor

Attributes:

Attribute MLIR Type Description
time_major BoolAttr bool attribute attribute
fused_activation_function StringAttr fused activation enum attribute

Results:

  1. output: tensor of any type values

tfl.unique (TFL::UniqueOp)

Unique Op.

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
idx_out_type Attribute derived attribute attribute

Results:

  1. output: tensor of any type values
  2. idx: tensor of any type values

tfl.unpack (TFL::UnpackOp)

Unpacks a tensor along a dimension into multiple tensors

Description:

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.

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
num IntegerAttr 32-bit integer attribute attribute
axis IntegerAttr 32-bit integer attribute attribute

Results:

  1. outputs: tensor of any type values

tfl.where (TFL::WhereOp)

Returns locations of nonzero / true values in a tensor.

Description:

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.

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. index: tensor of any type values

tfl.while (TFL::WhileOp)

While loop

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Attribute MLIR Type Description
is_stateless BoolAttr bool attribute attribute

Results:

  1. output: tensor of any type values

tfl.yield (TFL::YieldOp)

Yield operation

Description:

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

Operands:

  1. operands: any type

Attributes:

Results:

tfl.zeros_like (TFL::ZerosLikeOp)

ZerosLike operator

Description:

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

Operands:

  1. input: tensor of any type values

Attributes:

Results:

  1. output: tensor of any type values