emitpy.assign_global (tt::emitpy::AssignGlobalOp)

Assign a value to a global variable

The emitpy.assign_global assignes the value to an existing named global variable.

Example:

emitpy.assign_global @value = %arg0 : !emitpy.opaque<"[ttnn.Tensor]">

Interfaces: SymbolUserOpInterface

Attributes:

AttributeMLIR TypeDescription
name::mlir::FlatSymbolRefAttrflat symbol reference attribute

Operands:

OperandDescription
valueany type

emitpy.assign (tt::emitpy::AssignOp)

Assign operation

Syntax:

operation ::= `emitpy.assign` $value attr-dict `:` functional-type(operands, results)

The emitpy.assign operation represents a Python variable assignment. This models new_var = old_var or var = constant.

Example:

%2 = emitpy.assign %1 : <!emitpy.opaque<"ttnn.Tensor">>
// Code emitted for the operation above.
v2 = v1;

Operands:

OperandDescription
valueEmitPy opaque type

Results:

ResultDescription
resultany type

emitpy.call_opaque (tt::emitpy::CallOpaqueOp)

Opaque call operation

Syntax:

operation ::= `emitpy.call_opaque` $callee `(` $operands `)` attr-dict `:` functional-type($operands, results)

The emitpy.call_opaque operation represents a Python function call. The callee can be an arbitrary non-empty string.

Example:

%2 = emitpy.call_opaque "ttnn.add"(%0, %1) {args = [0 : index, 1 : index, #emitpy.opaque<"ttnn.DataType.BFLOAT16">, #emitpy.opaque<"ttnn.MemoryConfig(ttnn.TensorMemoryLayout.INTERLEAVED, ttnn.BufferType.DRAM, None)">], keyword_args = ["", "", "dtype", "memory_config"]} : (!emitpy.opaque<"ttnn.Tensor">, !emitpy.opaque<"ttnn.Tensor">) -> !emitpy.opaque<"ttnn.Tensor">

Interfaces: PyExpressionInterface

Attributes:

AttributeMLIR TypeDescription
callee::mlir::StringAttrstring attribute
args::mlir::ArrayAttrarray attribute
keyword_args::mlir::ArrayAttrstring array attribute

Operands:

OperandDescription
operandsvariadic of any type

Results:

ResultDescription
«unnamed»variadic of any type

emitpy.constant (tt::emitpy::ConstantOp)

Constant operation

The emitpy.constant operation produces an SSA value equal to some constant specified by an attribute. This can be used to form simple integer and floating point constants, as well as more exotic things like tensor constants.

Traits: ConstantLike

Attributes:

AttributeMLIR TypeDescription
value::mlir::AttributeAn opaque attribute or TypedAttr instance

Results:

ResultDescription
resultany type

emitpy.get_global (tt::emitpy::GetGlobalOp)

Obtain access to a global variable

Syntax:

operation ::= `emitpy.get_global` $name `:` type($result) attr-dict

The emitpy.get_global operation retrieves the value of a named global variable.

Example:

%1 = emitpy.get_global @x : !emitpy.opaque<"[ttnn.Tensor]">

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SymbolUserOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
name::mlir::FlatSymbolRefAttrflat symbol reference attribute

Results:

ResultDescription
resultany type

emitpy.global (tt::emitpy::GlobalOp)

A global variable

Syntax:

operation ::= `emitpy.global` $sym_name custom<EmitPyGlobalOpInitialValue>($initial_value) attr-dict

The emitpy.global operation defines a named global variable.

Example:

emitpy.global @x : #emitpy.opaque<"[]">

Interfaces: Symbol

Attributes:

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
initial_value::mlir::AttributeAn opaque attribute or TypedAttr instance

emitpy.global_statement (tt::emitpy::GlobalStatementOp)

Marks a variable as global for the current function scope

Syntax:

operation ::= `emitpy.global_statement` $name `:` type($result) attr-dict

The emitpy.global_statement operation represents a Python global statement.

It marks an identifier, specified by its symbol @name, as referring to a variable in the global (module) scope, rather than a new local variable.

Example:

%0 = emitpy.global_statement @x : !emitpy.opaque<"[ttnn.Tensor]">

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SymbolUserOpInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
name::mlir::FlatSymbolRefAttrflat symbol reference attribute

Results:

ResultDescription
resultany type

emitpy.import (tt::emitpy::ImportOp)

Import operation

The emitpy.import operation allows to define a Python module import via various forms of the import statement.

Example:

 emitpy.import import "ttnn"

Attributes:

AttributeMLIR TypeDescription
module_name::mlir::StringAttrstring attribute
module_alias::mlir::StringAttrstring attribute
members_to_import::mlir::ArrayAttrstring array attribute
member_aliases::mlir::ArrayAttrstring array attribute
import_all::mlir::UnitAttrunit attribute

emitpy.literal (tt::emitpy::LiteralOp)

Literal operation

Syntax:

operation ::= `emitpy.literal` $value attr-dict `:` type($result)

The emitpy.literal operation produces an SSA value equal to some constant specified by an attribute.

Example:

%0 = emitpy.literal "0" : index

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), PyExpressionInterface

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
value::mlir::StringAttrstring attribute

Results:

ResultDescription
resultindex

emitpy.subscript (tt::emitpy::SubscriptOp)

Subscript operation

Syntax:

operation ::= `emitpy.subscript` $value `[` $index `]` attr-dict `:` functional-type(operands, results)

With the emitpy.subscript operation the subscript operator [] can be applied to variables or arguments of opaque type.

Example:

%0 = emitpy.literal "0" : index
%1 = emitpy.subscript %arg0[%0] : (!emitpy.opaque<"[ttnn.Tensor]">, index) -> !emitpy.opaque<"ttnn.Tensor">

Interfaces: PyExpressionInterface

Operands:

OperandDescription
valueEmitPy opaque type
indexindex

Results:

ResultDescription
resultEmitPy opaque type

emitpy.verbatim (tt::emitpy::VerbatimOp)

Verbatim operation

Syntax:

operation ::= `emitpy.verbatim` $value (`args` $fmtArgs^ `:` type($fmtArgs))? attr-dict

The emitpy.verbatim operation produces no results and the value is emitted as is followed by a line break ('\n' character) during translation.

This operation can be used in situations where a more suitable operation is not yet implemented in the dialect.

Note: Use with caution. This operation can have arbitrary effects on the semantics of the emitted code. Use semantically more meaningful operations whenever possible. Additionally this op is NOT intended to be used to inject large snippets of code.

Attributes:

AttributeMLIR TypeDescription
value::mlir::StringAttrstring attribute

Operands:

OperandDescription
fmtArgsvariadic of any type