'math' Dialect
The math dialect is intended to hold mathematical operations on integer and floating types beyond simple arithmetics. Each operation works on scalar, vector or tensor type. On vector and tensor type operations apply elementwise unless explicitly specified otherwise. As an example, the floating point absolute value can be expressed as:
// Scalar absolute value.
%a = math.absf %b : f64
// Vector elementwise absolute value.
%f = math.absf %g : vector<4xf32>
// Tensor elementwise absolute value.
%x = math.absf %y : tensor<4x?xf8>
Operations ¶
math.absf
(math::AbsFOp) ¶
Floating point absolute-value operation
Syntax:
operation ::= `math.absf` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The absf
operation computes the absolute value. It takes one operand of
floating point type (i.e., scalar, tensor or vector) and returns one result
of the same type.
Example:
// Scalar absolute value.
%a = math.absf %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.absi
(math::AbsIOp) ¶
Integer absolute-value operation
Syntax:
operation ::= `math.absi` $operand attr-dict `:` type($result)
The absi
operation computes the absolute value. It takes one operand of
integer type (i.e., scalar, tensor or vector) and returns one result of the
same type.
Example:
// Scalar absolute value.
%a = math.absi %b : i64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
operand | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | signless-integer-like |
math.acos
(math::AcosOp) ¶
Arcus cosine of the specified value
Syntax:
operation ::= `math.acos` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The acos
operation computes the arcus cosine of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar arcus cosine value.
%a = math.acos %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.acosh
(math::AcoshOp) ¶
Hyperbolic arcus cosine of the given value
Syntax:
operation ::= `math.acosh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Syntax:
operation ::= ssa-id `=` `math.acosh` ssa-use `:` type
The acosh
operation computes the arcus cosine of a given value. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Hyperbolic arcus cosine of scalar value.
%a = math.acosh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.asin
(math::AsinOp) ¶
Arcus sine of the given value
Syntax:
operation ::= `math.asin` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Syntax:
operation ::= ssa-id `=` `math.asin` ssa-use `:` type
The asin
operation computes the arcus sine of a given value. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Arcus sine of scalar value.
%a = math.asin %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.asinh
(math::AsinhOp) ¶
Hyperbolic arcus sine of the given value
Syntax:
operation ::= `math.asinh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Syntax:
operation ::= ssa-id `=` `math.asinh` ssa-use `:` type
The asinh
operation computes the hyperbolic arcus sine of a given value. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Hyperbolic arcus sine of scalar value.
%a = math.asinh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.atan
(math::AtanOp) ¶
Arcus tangent of the given value
Syntax:
operation ::= `math.atan` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The atan
operation computes the arcus tangent of a given value. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Arcus tangent of scalar value.
%a = math.atan %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.atan2
(math::Atan2Op) ¶
2-argument arcus tangent of the given values
Syntax:
operation ::= `math.atan2` $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The atan2
operation takes two operands and returns one result, all of
which must be of the same type. The operands must be of floating point type
(i.e., scalar, tensor or vector).
The 2-argument arcus tangent atan2(y, x)
returns the angle in the
Euclidian plane between the positive x-axis and the ray through the point
(x, y). It is a generalization of the 1-argument arcus tangent which
returns the angle on the basis of the ratio y/x.
See also https://en.wikipedia.org/wiki/Atan2
Example:
// Scalar variant.
%a = math.atan2 %b, %c : f32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
lhs | floating-point-like |
rhs | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.atanh
(math::AtanhOp) ¶
Hyperbolic arcus tangent of the given value
Syntax:
operation ::= `math.atanh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Syntax:
operation ::= ssa-id `=` `math.atanh` ssa-use `:` type
The atanh
operation computes the hyperbolic arcus tangent of a given value. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Hyperbolic arcus tangent of scalar value.
%a = math.atanh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.cbrt
(math::CbrtOp) ¶
Cube root of the specified value
Syntax:
operation ::= `math.cbrt` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The cbrt
operation computes the cube root. It takes one operand of
floating point type (i.e., scalar, tensor or vector) and returns one result
of the same type. It has no standard attributes.
Example:
// Scalar cube root value.
%a = math.cbrt %b : f64
Note: This op is not equivalent to powf(…, 1/3.0).
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.ceil
(math::CeilOp) ¶
Ceiling of the specified value
Syntax:
operation ::= `math.ceil` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The ceil
operation computes the ceiling of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar ceiling value.
%a = math.ceil %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.copysign
(math::CopySignOp) ¶
A copysign operation
Syntax:
operation ::= `math.copysign` $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The copysign
returns a value with the magnitude of the first operand and
the sign of the second operand. It takes two operands and returns one result of
the same type. The operands must be of floating point type (i.e., scalar,
tensor or vector). It has no standard attributes.
Example:
// Scalar copysign value.
%a = math.copysign %b, %c : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
lhs | floating-point-like |
rhs | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.cos
(math::CosOp) ¶
Cosine of the specified value
Syntax:
operation ::= `math.cos` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The cos
operation computes the cosine of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar cosine value.
%a = math.cos %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.cosh
(math::CoshOp) ¶
Hyperbolic cosine of the specified value
Syntax:
operation ::= `math.cosh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The cosh
operation computes the hyperbolic cosine. It takes one operand
of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic cosine value.
%a = math.cosh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.ctlz
(math::CountLeadingZerosOp) ¶
Counts the leading zeros an integer value
Syntax:
operation ::= `math.ctlz` $operand attr-dict `:` type($result)
The ctlz
operation computes the number of leading zeros of an integer value.
It operates on scalar, tensor or vector.
Example:
// Scalar ctlz function value.
%a = math.ctlz %b : i32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
operand | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | signless-integer-like |
math.ctpop
(math::CtPopOp) ¶
Counts the number of set bits of an integer value
Syntax:
operation ::= `math.ctpop` $operand attr-dict `:` type($result)
The ctpop
operation computes the number of set bits of an integer value.
It operates on scalar, tensor or vector.
Example:
// Scalar ctpop function value.
%a = math.ctpop %b : i32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
operand | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | signless-integer-like |
math.cttz
(math::CountTrailingZerosOp) ¶
Counts the trailing zeros an integer value
Syntax:
operation ::= `math.cttz` $operand attr-dict `:` type($result)
The cttz
operation computes the number of trailing zeros of an integer value.
It operates on scalar, tensor or vector.
Example:
// Scalar cttz function value.
%a = math.cttz %b : i32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
operand | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | signless-integer-like |
math.erf
(math::ErfOp) ¶
Error function of the specified value
Syntax:
operation ::= `math.erf` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The erf
operation computes the error function. It takes one operand of
floating point type (i.e., scalar, tensor or vector) and returns one result of
the same type. It has no standard attributes.
Example:
// Scalar error function value.
%a = math.erf %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.exp
(math::ExpOp) ¶
Base-e exponential of the specified value
Syntax:
operation ::= `math.exp` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The exp
operation takes one operand of floating point type (i.e., scalar,
tensor or vector) and returns one result of the same type. It has no standard
attributes.
Example:
// Scalar natural exponential.
%a = math.exp %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.exp2
(math::Exp2Op) ¶
Base-2 exponential of the specified value
Syntax:
operation ::= `math.exp2` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The exp
operation takes one operand of floating point type (i.e., scalar,
tensor or vector) and returns one result of the same type. It has no standard
attributes.
Example:
// Scalar natural exponential.
%a = math.exp2 %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.expm1
(math::ExpM1Op) ¶
Base-e exponential of the specified value minus 1
Syntax:
operation ::= `math.expm1` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
expm1(x) := exp(x) - 1
The expm1
operation takes one operand of floating point type (i.e.,
scalar, tensor or vector) and returns one result of the same type. It has no
standard attributes.
Example:
// Scalar natural exponential minus 1.
%a = math.expm1 %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.floor
(math::FloorOp) ¶
Floor of the specified value
Syntax:
operation ::= `math.floor` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The floor
operation computes the floor of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar floor value.
%a = math.floor %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.fma
(math::FmaOp) ¶
Floating point fused multipy-add operation
Syntax:
operation ::= `math.fma` $a `,` $b `,` $c (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The fma
operation takes three operands and returns one result, each of
these is required to be the same type. Operands must be of floating point type
(i.e., scalar, tensor or vector).
Example:
// Scalar fused multiply-add: d = a*b + c
%d = math.fma %a, %b, %c : f64
The semantics of the operation correspond to those of the llvm.fma
intrinsic. In the
particular case of lowering to LLVM, this is guaranteed to lower
to the llvm.fma.*
intrinsic.
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
a | floating-point-like |
b | floating-point-like |
c | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.fpowi
(math::FPowIOp) ¶
Floating point raised to the signed integer power
Syntax:
operation ::= `math.fpowi` $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($lhs) `,` type($rhs)
The fpowi
operation takes a base
operand of floating point type
(i.e. scalar, tensor or vector) and a power
operand of integer type
(also scalar, tensor or vector) and returns one result of the same type
as base
. The result is base
raised to the power of power
.
The operation is elementwise for non-scalars, e.g.:
%v = math.fpowi %base, %power : vector<2xf32>, vector<2xi32
The result is a vector of:
[<math.fpowi %base[0], %power[0]>, <math.fpowi %base[1], %power[1]>]
Example:
// Scalar exponentiation.
%a = math.fpowi %base, %power : f64, i32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultShape
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
lhs | floating-point-like |
rhs | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.ipowi
(math::IPowIOp) ¶
Signed integer raised to the power of operation
Syntax:
operation ::= `math.ipowi` $lhs `,` $rhs attr-dict `:` type($result)
The ipowi
operation takes two operands of integer type (i.e., scalar,
tensor or vector) and returns one result of the same type. Operands
must have the same type.
Example:
// Scalar signed integer exponentiation.
%a = math.ipowi %b, %c : i32
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
lhs | signless-integer-like |
rhs | signless-integer-like |
Results: ¶
Result | Description |
---|---|
result | signless-integer-like |
math.log
(math::LogOp) ¶
Base-e logarithm of the specified value
Syntax:
operation ::= `math.log` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Computes the base-e logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log operation.
%y = math.log %x : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.log10
(math::Log10Op) ¶
Base-10 logarithm of the specified value
Syntax:
operation ::= `math.log10` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Computes the base-10 logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log10 operation.
%y = math.log10 %x : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.log1p
(math::Log1pOp) ¶
Computes the natural logarithm of one plus the given value
Syntax:
operation ::= `math.log1p` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Computes the base-e logarithm of one plus the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
log1p(x) := log(1 + x)
Example:
// Scalar log1p operation.
%y = math.log1p %x : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.log2
(math::Log2Op) ¶
Base-2 logarithm of the specified value
Syntax:
operation ::= `math.log2` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
Computes the base-2 logarithm of the given value. It takes one operand of floating point type (i.e., scalar, tensor or vector) and returns one result of the same type.
Example:
// Scalar log2 operation.
%y = math.log2 %x : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.powf
(math::PowFOp) ¶
Floating point raised to the power of operation
Syntax:
operation ::= `math.powf` $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The powf
operation takes two operands of floating point type (i.e.,
scalar, tensor or vector) and returns one result of the same type. Operands
must have the same type.
Example:
// Scalar exponentiation.
%a = math.powf %b, %c : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
lhs | floating-point-like |
rhs | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.round
(math::RoundOp) ¶
Round of the specified value
Syntax:
operation ::= `math.round` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The round
operation returns the operand rounded to the nearest integer
value in floating-point format. It takes one operand of floating point type
(i.e., scalar, tensor or vector) and produces one result of the same type. The
operation rounds the argument to the nearest integer value in floating-point
format, rounding halfway cases away from zero, regardless of the current
rounding direction.
Example:
// Scalar round operation.
%a = math.round %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.roundeven
(math::RoundEvenOp) ¶
Round of the specified value with halfway cases to even
Syntax:
operation ::= `math.roundeven` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The roundeven
operation returns the operand rounded to the nearest integer
value in floating-point format. It takes one operand of floating point type
(i.e., scalar, tensor or vector) and produces one result of the same type. The
operation rounds the argument to the nearest integer value in floating-point
format, rounding halfway cases to even, regardless of the current
rounding direction.
Example:
// Scalar round operation.
%a = math.roundeven %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.rsqrt
(math::RsqrtOp) ¶
Reciprocal of sqrt (1 / sqrt of the specified value)
Syntax:
operation ::= `math.rsqrt` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The rsqrt
operation computes the reciprocal of the square root. It takes
one operand of floating point type (i.e., scalar, tensor or vector) and returns
one result of the same type. It has no standard attributes.
Example:
// Scalar reciprocal square root value.
%a = math.rsqrt %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.sin
(math::SinOp) ¶
Sine of the specified value
Syntax:
operation ::= `math.sin` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The sin
operation computes the sine of a given value. It takes one
operand of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar sine value.
%a = math.sin %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.sinh
(math::SinhOp) ¶
Hyperbolic sine of the specified value
Syntax:
operation ::= `math.sinh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The sinh
operation computes the hyperbolic sine. It takes one operand
of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic sine value.
%a = math.sinh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.sqrt
(math::SqrtOp) ¶
Sqrt of the specified value
Syntax:
operation ::= `math.sqrt` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The sqrt
operation computes the square root. It takes one operand of
floating point type (i.e., scalar, tensor or vector) and returns one result of
the same type. It has no standard attributes.
Example:
// Scalar square root value.
%a = math.sqrt %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.tan
(math::TanOp) ¶
Tangent of the specified value
Syntax:
operation ::= `math.tan` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The tan
operation computes the tangent. It takes one operand
of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar tangent value.
%a = math.tan %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.tanh
(math::TanhOp) ¶
Hyperbolic tangent of the specified value
Syntax:
operation ::= `math.tanh` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The tanh
operation computes the hyperbolic tangent. It takes one operand
of floating point type (i.e., scalar, tensor or vector) and returns one
result of the same type. It has no standard attributes.
Example:
// Scalar hyperbolic tangent value.
%a = math.tanh %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
math.trunc
(math::TruncOp) ¶
Trunc of the specified value
Syntax:
operation ::= `math.trunc` $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result)
The trunc
operation returns the operand rounded to the nearest integer
value in floating-point format. It takes one operand of floating point type
(i.e., scalar, tensor or vector) and produces one result of the same type.
The operation always rounds to the nearest integer not larger in magnitude
than the operand, regardless of the current rounding direction.
Example:
// Scalar trunc operation.
%a = math.trunc %b : f64
Traits: AlwaysSpeculatableImplTrait
, Elementwise
, SameOperandsAndResultType
, Scalarizable
, Tensorizable
, Vectorizable
Interfaces: ArithFastMathInterface
, ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
, VectorUnrollOpInterface
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
fastmath | ::mlir::arith::FastMathFlagsAttr | Floating point fast math flagsEnum cases:
|
Operands: ¶
Operand | Description |
---|---|
operand | floating-point-like |
Results: ¶
Result | Description |
---|---|
result | floating-point-like |
Enums ¶
CmpFPredicate ¶
allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Cases: ¶
Symbol | Value | String |
---|---|---|
AlwaysFalse | 0 | false |
OEQ | 1 | oeq |
OGT | 2 | ogt |
OGE | 3 | oge |
OLT | 4 | olt |
OLE | 5 | ole |
ONE | 6 | one |
ORD | 7 | ord |
UEQ | 8 | ueq |
UGT | 9 | ugt |
UGE | 10 | uge |
ULT | 11 | ult |
ULE | 12 | ule |
UNE | 13 | une |
UNO | 14 | uno |
AlwaysTrue | 15 | true |
CmpIPredicate ¶
allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Cases: ¶
Symbol | Value | String |
---|---|---|
eq | 0 | eq |
ne | 1 | ne |
slt | 2 | slt |
sle | 3 | sle |
sgt | 4 | sgt |
sge | 5 | sge |
ult | 6 | ult |
ule | 7 | ule |
ugt | 8 | ugt |
uge | 9 | uge |
IntegerOverflowFlags ¶
Integer overflow arith flags
Cases: ¶
Symbol | Value | String |
---|---|---|
none | 0 | none |
nsw | 1 | nsw |
nuw | 2 | nuw |
RoundingMode ¶
Floating point rounding mode
Cases: ¶
Symbol | Value | String |
---|---|---|
to_nearest_even | 0 | to_nearest_even |
downward | 1 | downward |
upward | 2 | upward |
toward_zero | 3 | toward_zero |
to_nearest_away | 4 | to_nearest_away |
AtomicRMWKind ¶
allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
Cases: ¶
Symbol | Value | String |
---|---|---|
addf | 0 | addf |
addi | 1 | addi |
assign | 2 | assign |
maximumf | 3 | maximumf |
maxs | 4 | maxs |
maxu | 5 | maxu |
minimumf | 6 | minimumf |
mins | 7 | mins |
minu | 8 | minu |
mulf | 9 | mulf |
muli | 10 | muli |
ori | 11 | ori |
andi | 12 | andi |
maxnumf | 13 | maxnumf |
minnumf | 14 | minnumf |
FastMathFlags ¶
Floating point fast math flags
Cases: ¶
Symbol | Value | String |
---|---|---|
none | 0 | none |
reassoc | 1 | reassoc |
nnan | 2 | nnan |
ninf | 4 | ninf |
nsz | 8 | nsz |
arcp | 16 | arcp |
contract | 32 | contract |
afn | 64 | afn |
fast | 127 | fast |