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>

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>

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex 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.complex operation creates a complex number from two floating-point operands, the real and the imaginary part.

Example:

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

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>

Operands: 

OperandDescription
lhscomplex type with floating-point elements
rhscomplex 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>

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
imaginaryfloating-point

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>

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>

Operands: 

OperandDescription
complexcomplex type with floating-point elements

Results: 

ResultDescription
realfloating-point

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>

Operands: 

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

Results: 

ResultDescription
resultcomplex type with floating-point elements