ArithExt

ArithExt ops

arith_ext.add (heir::arith_ext::AddOp)

Modular addition operation

Syntax:

operation ::= `arith_ext.add` operands attr-dict `:` type($output)

Computes addition modulo a statically known modulus $q$.

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

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
modulus::mlir::IntegerAttrarbitrary integer attribute

Operands:

OperandDescription
lhssignless-integer-like
rhssignless-integer-like

Results:

ResultDescription
outputsignless-integer-like

arith_ext.barrett_reduce (heir::arith_ext::BarrettReduceOp)

Compute the first step of the Barrett reduction.

Syntax:

operation ::= `arith_ext.barrett_reduce` operands attr-dict `:` qualified(type($input))

Let $q$ denote a statically known modulus and $b = 4^{w}$, where $w$ is the smallest bit-width that contains the range $[0, q)$. The Barrett reduce operation computes barret_reduce x = x - floor(x * floor(b / q) / b) * q.

Given $0 <= x < q^2$, then this will compute $(x \mod q)$ or $(x \mod q) + p$.

Traits: SameOperandsAndResultType

Interfaces: InferTypeOpInterface

Attributes:

AttributeMLIR TypeDescription
modulus::mlir::IntegerAttrarbitrary integer attribute

Operands:

OperandDescription
inputsignless-integer-like

Results:

ResultDescription
outputsignless-integer-like

arith_ext.mac (heir::arith_ext::MacOp)

Modular multiplication-and-accumulation operation

Syntax:

operation ::= `arith_ext.mac` operands attr-dict `:` type($output)

arith_ext.mac x, y, z {modulus = q} computes $(x * y) + z \mod q$

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

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
modulus::mlir::IntegerAttrarbitrary integer attribute

Operands:

OperandDescription
lhssignless-integer-like
rhssignless-integer-like
accsignless-integer-like

Results:

ResultDescription
outputsignless-integer-like

arith_ext.mul (heir::arith_ext::MulOp)

Modular multiplication operation

Syntax:

operation ::= `arith_ext.mul` operands attr-dict `:` type($output)

Computes multiplication modulo a statically known modulus $q$.

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

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
modulus::mlir::IntegerAttrarbitrary integer attribute

Operands:

OperandDescription
lhssignless-integer-like
rhssignless-integer-like

Results:

ResultDescription
outputsignless-integer-like

arith_ext.subifge (heir::arith_ext::SubIfGEOp)

Compute (x >= y) ? x - y : x.

Syntax:

operation ::= `arith_ext.subifge` operands attr-dict `:` qualified(type($output))

Traits: SameOperandsAndResultType

Interfaces: InferTypeOpInterface

Operands:

OperandDescription
lhssignless-integer-like
rhssignless-integer-like

Results:

ResultDescription
outputsignless-integer-like

arith_ext.sub (heir::arith_ext::SubOp)

Modular subtraction operation

Syntax:

operation ::= `arith_ext.sub` operands attr-dict `:` type($output)

Computes subtraction modulo a statically known modulus $q$.

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

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
modulus::mlir::IntegerAttrarbitrary integer attribute

Operands:

OperandDescription
lhssignless-integer-like
rhssignless-integer-like

Results:

ResultDescription
outputsignless-integer-like