# 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) ¶

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.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>


#### 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.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>


#### 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>


#### 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>


#### 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>


#### 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>


#### 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>  #### 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>  #### 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>


#### Operands: ¶

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

#### Results: ¶

ResultDescription
result1-bit signless integer

### 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.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>


#### 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>


#### Operands: ¶

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

#### Results: ¶

ResultDescription
resultcomplex type with floating-point elements