Skip to content

Commit ddda156

Browse files
lhutton1aokblast
authored andcommitted
[mlir][tosa] Move variable op definitions to TosaOps.td (NFC) (llvm#165260)
Variable ops (VARIABLE/VARIABLE_READ/VARIABLE_WRITE) are part of the TOSA specification and should therefore be defined in `TosaOps.td`.
1 parent fcf5109 commit ddda156

File tree

2 files changed

+101
-101
lines changed

2 files changed

+101
-101
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include "mlir/IR/OpBase.td"
1919
include "mlir/Interfaces/SideEffectInterfaces.td"
2020
include "mlir/Interfaces/InferTypeOpInterface.td"
2121
include "mlir/Interfaces/LoopLikeInterface.td"
22+
include "mlir/IR/SymbolInterfaces.td"
2223
include "mlir/Dialect/Tosa/IR/TosaInterfaces.td"
2324

2425
include "mlir/Dialect/Tosa/IR/TosaTypesBase.td"
@@ -2814,6 +2815,106 @@ def Tosa_WhileOp : Tosa_Op<"while_loop", [
28142815
let hasVerifier = 1;
28152816
}
28162817

2818+
//===----------------------------------------------------------------------===//
2819+
// Operator: variable
2820+
//===----------------------------------------------------------------------===//
2821+
def Tosa_VariableOp : Tosa_Op<"variable", [Symbol]> {
2822+
let summary = "Defines a variable";
2823+
2824+
let description = [{
2825+
Defines a new TOSA variable. This is a persistent mutable value across multiple
2826+
TOSA graph invocations. Modifications are expressed using read/write semantics.
2827+
}];
2828+
2829+
let arguments = (ins
2830+
// Note: "sym_name" is used as opposed to "name" in the specification,
2831+
// since a Symbol must be named "sym_name" for it to be recognised by
2832+
// the containing SymbolTable.
2833+
SymbolNameAttr:$sym_name,
2834+
IndexElementsAttr:$var_shape,
2835+
TypeAttr:$type,
2836+
OptionalAttr<AnyAttr>:$initial_value
2837+
);
2838+
2839+
list<Availability> availability = [
2840+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
2841+
Extension<[Tosa_EXT_VARIABLE]>,
2842+
];
2843+
2844+
let hasCustomAssemblyFormat = 1;
2845+
2846+
let assemblyFormat = [{
2847+
$sym_name
2848+
attr-dict
2849+
custom<VariableOpTypeOrInitialValue>($var_shape, $type, $initial_value)
2850+
}];
2851+
2852+
let builders = [Tosa_VariableOpBuilder];
2853+
2854+
let extraClassDeclaration = [{
2855+
::llvm::StringRef getName() {
2856+
return getSymName();
2857+
}
2858+
}];
2859+
}
2860+
2861+
//===----------------------------------------------------------------------===//
2862+
// Operator: variable_write
2863+
//===----------------------------------------------------------------------===//
2864+
def Tosa_VariableWriteOp : Tosa_Op<"variable_write", []> {
2865+
let summary = "write_buffer operator";
2866+
2867+
let description = [{
2868+
Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.
2869+
}];
2870+
2871+
let arguments = (ins
2872+
SymbolNameAttr:$name,
2873+
Tosa_Tensor:$input1
2874+
);
2875+
2876+
list<Availability> availability = [
2877+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
2878+
Extension<[Tosa_EXT_VARIABLE]>,
2879+
];
2880+
2881+
let assemblyFormat = [{
2882+
$name attr-dict `,` $input1 `:` type($input1)
2883+
}];
2884+
2885+
let hasVerifier = 1;
2886+
}
2887+
2888+
//===----------------------------------------------------------------------===//
2889+
// Operator: variable_read
2890+
//===----------------------------------------------------------------------===//
2891+
def Tosa_VariableReadOp : Tosa_Op<"variable_read", []> {
2892+
let summary = "read_buffer operator";
2893+
2894+
let description = [{
2895+
Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.
2896+
}];
2897+
2898+
let arguments = (ins
2899+
SymbolNameAttr:$name
2900+
);
2901+
2902+
let results = (outs
2903+
Tosa_Tensor:$output1
2904+
);
2905+
2906+
list<Availability> availability = [
2907+
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
2908+
Extension<[Tosa_EXT_VARIABLE]>,
2909+
];
2910+
2911+
let assemblyFormat = [{
2912+
$name attr-dict `:` type($output1)
2913+
}];
2914+
2915+
let hasVerifier = 1;
2916+
}
2917+
28172918
include "mlir/Dialect/Tosa/IR/TosaUtilOps.td"
28182919

28192920
include "mlir/Dialect/Tosa/IR/TosaShapeOps.td"

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

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
include "mlir/IR/OpBase.td"
1919

2020
include "mlir/Interfaces/SideEffectInterfaces.td"
21-
include "mlir/IR/SymbolInterfaces.td"
2221
include "mlir/Interfaces/LoopLikeInterface.td"
2322
include "mlir/Interfaces/VectorInterfaces.td"
2423
include "mlir/Dialect/Tosa/IR/TosaInterfaces.td"
@@ -80,104 +79,4 @@ def Tosa_YieldOp : Tosa_Op<"yield", [
8079
let assemblyFormat = "$inputs attr-dict `:` type($inputs)";
8180
}
8281

83-
//===----------------------------------------------------------------------===//
84-
// Operator: variable
85-
//===----------------------------------------------------------------------===//
86-
def Tosa_VariableOp : Tosa_Op<"variable", [Symbol]> {
87-
let summary = "Defines a variable";
88-
89-
let description = [{
90-
Defines a new TOSA variable. This is a persistent mutable value across multiple
91-
TOSA graph invocations. Modifications are expressed using read/write semantics.
92-
}];
93-
94-
let arguments = (ins
95-
// Note: "sym_name" is used as opposed to "name" in the specification,
96-
// since a Symbol must be named "sym_name" for it to be recognised by
97-
// the containing SymbolTable.
98-
SymbolNameAttr:$sym_name,
99-
IndexElementsAttr:$var_shape,
100-
TypeAttr:$type,
101-
OptionalAttr<AnyAttr>:$initial_value
102-
);
103-
104-
list<Availability> availability = [
105-
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
106-
Extension<[Tosa_EXT_VARIABLE]>,
107-
];
108-
109-
let hasCustomAssemblyFormat = 1;
110-
111-
let assemblyFormat = [{
112-
$sym_name
113-
attr-dict
114-
custom<VariableOpTypeOrInitialValue>($var_shape, $type, $initial_value)
115-
}];
116-
117-
let builders = [Tosa_VariableOpBuilder];
118-
119-
let extraClassDeclaration = [{
120-
::llvm::StringRef getName() {
121-
return getSymName();
122-
}
123-
}];
124-
}
125-
126-
//===----------------------------------------------------------------------===//
127-
// Operator: variable_write
128-
//===----------------------------------------------------------------------===//
129-
def Tosa_VariableWriteOp : Tosa_Op<"variable_write", []> {
130-
let summary = "write_buffer operator";
131-
132-
let description = [{
133-
Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.
134-
}];
135-
136-
let arguments = (ins
137-
SymbolNameAttr:$name,
138-
Tosa_Tensor:$input1
139-
);
140-
141-
list<Availability> availability = [
142-
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
143-
Extension<[Tosa_EXT_VARIABLE]>,
144-
];
145-
146-
let assemblyFormat = [{
147-
$name attr-dict `,` $input1 `:` type($input1)
148-
}];
149-
150-
let hasVerifier = 1;
151-
}
152-
153-
//===----------------------------------------------------------------------===//
154-
// Operator: variable_read
155-
//===----------------------------------------------------------------------===//
156-
def Tosa_VariableReadOp : Tosa_Op<"variable_read", []> {
157-
let summary = "read_buffer operator";
158-
159-
let description = [{
160-
Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.
161-
}];
162-
163-
let arguments = (ins
164-
SymbolNameAttr:$name
165-
);
166-
167-
let results = (outs
168-
Tosa_Tensor:$output1
169-
);
170-
171-
list<Availability> availability = [
172-
Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
173-
Extension<[Tosa_EXT_VARIABLE]>,
174-
];
175-
176-
let assemblyFormat = [{
177-
$name attr-dict `:` type($output1)
178-
}];
179-
180-
let hasVerifier = 1;
181-
}
182-
18382
#endif // TOSA_UTIL_OPS

0 commit comments

Comments
 (0)