Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include "mlir/IR/OpBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Dialect/Tosa/IR/TosaInterfaces.td"

include "mlir/Dialect/Tosa/IR/TosaTypesBase.td"
Expand Down Expand Up @@ -2751,6 +2752,106 @@ def Tosa_WhileOp : Tosa_Op<"while_loop", [
let hasVerifier = 1;
}

//===----------------------------------------------------------------------===//
// Operator: variable
//===----------------------------------------------------------------------===//
def Tosa_VariableOp : Tosa_Op<"variable", [Symbol]> {
let summary = "Defines a variable";

let description = [{
Defines a new TOSA variable. This is a persistent mutable value across multiple
TOSA graph invocations. Modifications are expressed using read/write semantics.
}];

let arguments = (ins
// Note: "sym_name" is used as opposed to "name" in the specification,
// since a Symbol must be named "sym_name" for it to be recognised by
// the containing SymbolTable.
SymbolNameAttr:$sym_name,
IndexElementsAttr:$var_shape,
TypeAttr:$type,
OptionalAttr<AnyAttr>:$initial_value
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let hasCustomAssemblyFormat = 1;

let assemblyFormat = [{
$sym_name
attr-dict
custom<VariableOpTypeOrInitialValue>($var_shape, $type, $initial_value)
}];

let builders = [Tosa_VariableOpBuilder];

let extraClassDeclaration = [{
::llvm::StringRef getName() {
return getSymName();
}
}];
}

//===----------------------------------------------------------------------===//
// Operator: variable_write
//===----------------------------------------------------------------------===//
def Tosa_VariableWriteOp : Tosa_Op<"variable_write", []> {
let summary = "write_buffer operator";

let description = [{
Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.
}];

let arguments = (ins
SymbolNameAttr:$name,
Tosa_Tensor:$input1
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let assemblyFormat = [{
$name attr-dict `,` $input1 `:` type($input1)
}];

let hasVerifier = 1;
}

//===----------------------------------------------------------------------===//
// Operator: variable_read
//===----------------------------------------------------------------------===//
def Tosa_VariableReadOp : Tosa_Op<"variable_read", []> {
let summary = "read_buffer operator";

let description = [{
Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.
}];

let arguments = (ins
SymbolNameAttr:$name
);

let results = (outs
Tosa_Tensor:$output1
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let assemblyFormat = [{
$name attr-dict `:` type($output1)
}];

let hasVerifier = 1;
}

include "mlir/Dialect/Tosa/IR/TosaUtilOps.td"

include "mlir/Dialect/Tosa/IR/TosaShapeOps.td"
Expand Down
101 changes: 0 additions & 101 deletions mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
include "mlir/IR/OpBase.td"

include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/Interfaces/VectorInterfaces.td"
include "mlir/Dialect/Tosa/IR/TosaInterfaces.td"
Expand Down Expand Up @@ -80,104 +79,4 @@ def Tosa_YieldOp : Tosa_Op<"yield", [
let assemblyFormat = "$inputs attr-dict `:` type($inputs)";
}

//===----------------------------------------------------------------------===//
// Operator: variable
//===----------------------------------------------------------------------===//
def Tosa_VariableOp : Tosa_Op<"variable", [Symbol]> {
let summary = "Defines a variable";

let description = [{
Defines a new TOSA variable. This is a persistent mutable value across multiple
TOSA graph invocations. Modifications are expressed using read/write semantics.
}];

let arguments = (ins
// Note: "sym_name" is used as opposed to "name" in the specification,
// since a Symbol must be named "sym_name" for it to be recognised by
// the containing SymbolTable.
SymbolNameAttr:$sym_name,
IndexElementsAttr:$var_shape,
TypeAttr:$type,
OptionalAttr<AnyAttr>:$initial_value
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let hasCustomAssemblyFormat = 1;

let assemblyFormat = [{
$sym_name
attr-dict
custom<VariableOpTypeOrInitialValue>($var_shape, $type, $initial_value)
}];

let builders = [Tosa_VariableOpBuilder];

let extraClassDeclaration = [{
::llvm::StringRef getName() {
return getSymName();
}
}];
}

//===----------------------------------------------------------------------===//
// Operator: variable_write
//===----------------------------------------------------------------------===//
def Tosa_VariableWriteOp : Tosa_Op<"variable_write", []> {
let summary = "write_buffer operator";

let description = [{
Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.
}];

let arguments = (ins
SymbolNameAttr:$name,
Tosa_Tensor:$input1
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let assemblyFormat = [{
$name attr-dict `,` $input1 `:` type($input1)
}];

let hasVerifier = 1;
}

//===----------------------------------------------------------------------===//
// Operator: variable_read
//===----------------------------------------------------------------------===//
def Tosa_VariableReadOp : Tosa_Op<"variable_read", []> {
let summary = "read_buffer operator";

let description = [{
Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.
}];

let arguments = (ins
SymbolNameAttr:$name
);

let results = (outs
Tosa_Tensor:$output1
);

list<Availability> availability = [
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
Extension<[Tosa_EXT_VARIABLE]>,
];

let assemblyFormat = [{
$name attr-dict `:` type($output1)
}];

let hasVerifier = 1;
}

#endif // TOSA_UTIL_OPS