MLIR

Multi-Level IR Compiler Framework

Dialect 'fxpmath' definition

Operation definition

fxpmath.clampis (fxpmath::ClampISOp)

Clamps a signed-integer like argument to a min/max range.

Description:

Element-wise equivalent to: r = std::min(clamp_max, std::max(e, clamp_min))

Operands:

  1. operand: integer-like

Attributes:

AttributeMLIR TypeDescription
clamp_minIntegerAttrarbitrary integer attribute attribute
clamp_maxIntegerAttrarbitrary integer attribute attribute

Results:

  1. «unnamed»: integer-like

fxpmath.convertis (fxpmath::ConvertISOp)

Does an element-wise conversion from a signed integer to signed integer

Description:

Similar to an element-wise static_cast in C++, from a one signed integer element type to another.

Operands:

  1. operand: integer-like

Attributes:

Results:

  1. «unnamed»: integer-like

fxpmath.convertistof (fxpmath::ConvertISToFOp)

Does an element-wise conversion from a signed integer to a float

Description:

Similar to an element-wise static_cast in C++, from a signed integer element type to a floating point element type, rounding to the nearest floating point value.

Operands:

  1. operand: integer-like

Attributes:

Results:

  1. «unnamed»: floating-point-like

fxpmath.real_add_ew (fxpmath::RealAddEwOp)

Description:

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.compare (fxpmath::RealCompareZeroEwOp)

Description:

Compares a real value to zero, returning an I1 (boolean) tensor with the result of applying the comparison function.

Operands:

  1. operand: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
fnStringAttrType of subtraction-result comparison to perform. attribute

Results:

  1. res: tensor of 1-bit integer values

fxpmath.real_div_ew (fxpmath::RealDivEwOp)

Description:

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.real_matmul_bias (fxpmath::RealMatMulBiasOp)

Matmul with bias

Description:

A specialization of a RealMatMulOp that also accepts an [n] dimension bias vector.

In addition, there is often special support for a fused bias and clamp, which is why they are included.

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  3. bias: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.real_matmul (fxpmath::RealMatMulOp)

Matmul

Description:

A matrix multiply of [m, k] and [k, n] -> [m, n] where the bias vector is of shape [n]. Also accepts rank 3 or more input tensors, in which case the leading dimensions are batch dims.

Many real systems have specific library calls optimized for this precise operation, which is why it is handled explicitly versus purely as a generalized tensor contraction.

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.real_mul_ew (fxpmath::RealMulEwOp)

Description:

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.real_sub_ew (fxpmath::RealSubEwOp)

Description:

Operands:

  1. lhs: primitive/tensor/vector of real valued primitive (float or quantized type)
  2. rhs: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.real_unary_ew (fxpmath::RealUnaryEwOp)

Description:

Operands:

  1. operand: primitive/tensor/vector of real valued primitive (float or quantized type)

Attributes:

AttributeMLIR TypeDescription
fnStringAttrelement-wise unary function attribute
clamp_minFloatAttr64-bit float attribute attribute
clamp_maxFloatAttr64-bit float attribute attribute

Results:

  1. res: primitive/tensor/vector of real valued primitive (float or quantized type)

fxpmath.rounding_divide_by_potis (fxpmath::RoundingDivideByPotISOp)

Computes a rounding arithmetic right shift.

Description:

Computes integer division by a power-of-two, correctly rounded-to-nearest. Also known as a rounding arithmetic right shift. See gemmlowp::RoundingDivideByPOT for a reference implementation.

Operands:

  1. operand: integer-like

Attributes:

AttributeMLIR TypeDescription
exponentIntegerAttrarbitrary integer attribute attribute

Results:

  1. res: integer-like

fxpmath.vs_saturating_rounding_doubling_high_mulis (fxpmath::VecScalarSaturatingRoundingDoublingHighMulISOp)

Implements equivalent functionality to ARMv7 NEON VQRDMULH

Description:

Equivalent to the ARMv7 NEON VQRDMULH instruction. See gemmlowp::SaturatingRoundingDoublingHighMul for a reference implementation.

Operands:

  1. a: integer-like

Attributes:

AttributeMLIR TypeDescription
bIntegerAttrarbitrary integer attribute attribute

Results:

  1. «unnamed»: integer-like