MLIR

Multi-Level IR Compiler Framework

'complex' Dialect

The complex dialect is intended to hold complex numbers creation and arithmetic ops.

Operation definition 

complex.abs (::mlir::complex::AbsOp) 

computes absolute value of a complex number

Syntax:

operation ::= `complex.abs` $complex attr-dict `:` type($complex)

The abs op takes a single complex number and computes its absolute value.

Example:

%a = complex.abs %b : complex<f32>

Traits: Elementwise

Interfaces: NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultfloating-point

complex.add (::mlir::complex::AddOp) 

complex addition

Syntax:

operation ::= `complex.add` $lhs `,` $rhs  attr-dict `:` type($result)

The add operation takes two complex numbers and returns their sum.

Example:

%a = complex.add %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.angle (::mlir::complex::AngleOp) 

computes argument value of a complex number

Syntax:

operation ::= `complex.angle` $complex attr-dict `:` type($complex)

The angle op takes a single complex number and computes its argument value with a branch cut along the negative real axis.

Example:

     %a = complex.angle %b : complex<f32>

Traits: Elementwise

Interfaces: NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultfloating-point

complex.atan2 (::mlir::complex::Atan2Op) 

complex 2-argument arctangent

Syntax:

operation ::= `complex.atan2` $lhs `,` $rhs  attr-dict `:` type($result)

For complex numbers it is expressed using complex logarithm atan2(y, x) = -i * log((x + i * y) / sqrt(x2 + y2))

Example:

%a = complex.atan2 %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.conj (::mlir::complex::ConjOp) 

Calculate the complex conjugate

Syntax:

operation ::= `complex.conj` $complex attr-dict `:` type($complex)

The conj op takes a single complex number and computes the complex conjugate.

Example:

%a = complex.conj %b: complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.constant (::mlir::complex::ConstantOp) 

complex number constant operation

Syntax:

operation ::= `complex.constant` $value attr-dict `:` type($complex)

The complex.constant operation creates a constant complex number from an attribute containing the real and imaginary parts.

Example:

%a = complex.constant [0.1, -1.0] : complex<f64>

Traits: ConstantLike

Interfaces: NoSideEffect (MemoryEffectOpInterface), OpAsmOpInterface

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
value::mlir::ArrayAttrarray attribute

Results: 

ResultDescription
complexcomplex type with floating-point elements

complex.cos (::mlir::complex::CosOp) 

computes cosine of a complex number

Syntax:

operation ::= `complex.cos` $complex attr-dict `:` type($complex)

The cos op takes a single complex number and computes the cosine of it, i.e. cos(x), where x is the input value.

Example:

%a = complex.cos %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.create (::mlir::complex::CreateOp) 

complex number creation operation

Syntax:

operation ::= `complex.create` $real `,` $imaginary attr-dict `:` type($complex)

The complex.create operation creates a complex number from two floating-point operands, the real and the imaginary part.

Example:

%a = complex.create %b, %c : complex<f32>

Interfaces: NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
realfloating-point
imaginaryfloating-point

Results: 

ResultDescription
complexcomplex type with floating-point elements

complex.div (::mlir::complex::DivOp) 

complex division

Syntax:

operation ::= `complex.div` $lhs `,` $rhs  attr-dict `:` type($result)

The div operation takes two complex numbers and returns result of their division:

%a = complex.div %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.eq (::mlir::complex::EqualOp) 

computes whether two complex values are equal

Syntax:

operation ::= `complex.eq` $lhs `,` $rhs  attr-dict `:` type($lhs)

The eq op takes two complex numbers and returns whether they are equal.

Example:

%a = complex.eq %b, %c : complex<f32>

Traits: Elementwise

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
result1-bit signless integer

complex.exp (::mlir::complex::ExpOp) 

computes exponential of a complex number

Syntax:

operation ::= `complex.exp` $complex attr-dict `:` type($complex)

The exp op takes a single complex number and computes the exponential of it, i.e. exp(x) or e^(x), where x is the input value. e denotes Euler’s number and is approximately equal to 2.718281.

Example:

%a = complex.exp %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.expm1 (::mlir::complex::Expm1Op) 

computes exponential of a complex number minus 1

Syntax:

operation ::= `complex.expm1` $complex attr-dict `:` type($complex)

Syntax:

operation ::= ssa-id `=` `complex.expm1` ssa-use `:` type

complex.expm1(x) := complex.exp(x) - 1

Example:

%a = complex.expm1 %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.im (::mlir::complex::ImOp) 

extracts the imaginary part of a complex number

Syntax:

operation ::= `complex.im` $complex attr-dict `:` type($complex)

The im op takes a single complex number and extracts the imaginary part.

Example:

%a = complex.im %b : complex<f32>

Traits: Elementwise

Interfaces: NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
imaginaryfloating-point

complex.log1p (::mlir::complex::Log1pOp) 

computes natural logarithm of a complex number

Syntax:

operation ::= `complex.log1p` $complex attr-dict `:` type($complex)

The log op takes a single complex number and computes the natural logarithm of one plus the given value, i.e. log(1 + x) or log_e(1 + x), where x is the input value. e denotes Euler’s number and is approximately equal to 2.718281.

Example:

%a = complex.log1p %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.log (::mlir::complex::LogOp) 

computes natural logarithm of a complex number

Syntax:

operation ::= `complex.log` $complex attr-dict `:` type($complex)

The log op takes a single complex number and computes the natural logarithm of it, i.e. log(x) or log_e(x), where x is the input value. e denotes Euler’s number and is approximately equal to 2.718281.

Example:

%a = complex.log %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.mul (::mlir::complex::MulOp) 

complex multiplication

Syntax:

operation ::= `complex.mul` $lhs `,` $rhs  attr-dict `:` type($result)

The mul operation takes two complex numbers and returns their product:

%a = complex.mul %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.neg (::mlir::complex::NegOp) 

Negation operator

Syntax:

operation ::= `complex.neg` $complex attr-dict `:` type($complex)

The neg op takes a single complex number complex and returns -complex.

Example:

%a = complex.neg %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.neq (::mlir::complex::NotEqualOp) 

computes whether two complex values are not equal

Syntax:

operation ::= `complex.neq` $lhs `,` $rhs  attr-dict `:` type($lhs)

The neq op takes two complex numbers and returns whether they are not equal.

Example:

%a = complex.neq %b, %c : complex<f32>

Traits: Elementwise

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
result1-bit signless integer

complex.pow (::mlir::complex::PowOp) 

complex power function

Syntax:

operation ::= `complex.pow` $lhs `,` $rhs  attr-dict `:` type($result)

The sqrt operation takes a complex number raises it to the given complex exponent.

Example:

%a = complex.pow %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.re (::mlir::complex::ReOp) 

extracts the real part of a complex number

Syntax:

operation ::= `complex.re` $complex attr-dict `:` type($complex)

The re op takes a single complex number and extracts the real part.

Example:

%a = complex.re %b : complex<f32>

Traits: Elementwise

Interfaces: NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
realfloating-point

complex.rsqrt (::mlir::complex::RsqrtOp) 

complex reciprocal of square root

Syntax:

operation ::= `complex.rsqrt` $complex attr-dict `:` type($complex)

The rsqrt operation computes reciprocal of square root.

Example:

%a = complex.rsqrt %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.sign (::mlir::complex::SignOp) 

computes sign of a complex number

Syntax:

operation ::= `complex.sign` $complex attr-dict `:` type($complex)

The sign op takes a single complex number and computes the sign of it, i.e. y = sign(x) = x / |x| if x != 0, otherwise y = 0.

Example:

%a = complex.sign %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.sin (::mlir::complex::SinOp) 

computes sine of a complex number

Syntax:

operation ::= `complex.sin` $complex attr-dict `:` type($complex)

The sin op takes a single complex number and computes the sine of it, i.e. sin(x), where x is the input value.

Example:

%a = complex.sin %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.sqrt (::mlir::complex::SqrtOp) 

complex square root

Syntax:

operation ::= `complex.sqrt` $complex attr-dict `:` type($complex)

The sqrt operation takes a complex number and returns its square root.

Example:

%a = complex.sqrt %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.sub (::mlir::complex::SubOp) 

complex subtraction

Syntax:

operation ::= `complex.sub` $lhs `,` $rhs  attr-dict `:` type($result)

The sub operation takes two complex numbers and returns their difference.

Example:

%a = complex.sub %b, %c : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.tan (::mlir::complex::TanOp) 

computes tangent of a complex number

Syntax:

operation ::= `complex.tan` $complex attr-dict `:` type($complex)

The tan op takes a single complex number and computes the tangent of it, i.e. tan(x), where x is the input value.

Example:

%a = complex.tan %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements

complex.tanh (::mlir::complex::TanhOp) 

complex hyperbolic tangent

Syntax:

operation ::= `complex.tanh` $complex attr-dict `:` type($complex)

The tanh operation takes a complex number and returns its hyperbolic tangent.

Example:

%a = complex.tanh %b : complex<f32>

Traits: Elementwise, SameOperandsAndResultType

Interfaces: InferTypeOpInterface, NoSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
resultcomplex type with floating-point elements