MathExt

‘math_ext’ Dialect

Math-related operations we require for HEIR which do not (yet) exist in upstream math.

MathExt ops

math_ext.sigmoid (heir::math_ext::SigmoidOp)

Returns elementwise sigmoid of the input value

Syntax:

operation ::= `math_ext.sigmoid` $value attr-dict `:` type($result)

Applies the sigmoid logistic function to each element of the input: $$\sigma(x)=\frac{1}{1+\exp{−x}}$$

Traits: AlwaysSpeculatableImplTrait, Elementwise, SameOperandsAndResultType, Scalarizable, Tensorizable, Vectorizable

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

OperandDescription
valuefloating-point-like

Results:

ResultDescription
resultfloating-point-like

math_ext.sign (heir::math_ext::SignOp)

Returns the sign of the input value

Syntax:

operation ::= `math_ext.sign` $value attr-dict `:` type($result)

Returns -1 if the input is negative, 0 if it is zero, and 1 if it is positive. The behavior is undefined for NaN inputs.

Traits: AlwaysSpeculatableImplTrait, Elementwise, SameOperandsAndResultType, Scalarizable, Tensorizable, Vectorizable

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

OperandDescription
valuesignless-integer-like or floating-point-like

Results:

ResultDescription
resultsignless-integer-like or floating-point-like