@@ -171,7 +171,8 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
171
171
advanced cases.
172
172
173
173
This op is side effecting and may not be valid to use in graph regions
174
- without additional consideration to evaluation order constraints.
174
+ without additional consideration to evaluation order constraints. See
175
+ `global_load_graph` for op which allows for explicit ordering constraints.
175
176
176
177
Example:
177
178
@@ -181,16 +182,14 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
181
182
}];
182
183
183
184
let arguments = (ins
184
- Arg<SymbolRefAttr, "", [MemRead]>:$global,
185
- Variadic<MLProgram_TokenType>:$consumeTokens
185
+ Arg<SymbolRefAttr, "", [MemRead]>:$global
186
186
);
187
187
let results = (outs
188
- AnyType:$result,
189
- Optional<MLProgram_TokenType>:$produceToken
188
+ AnyType:$result
190
189
);
191
190
192
191
let assemblyFormat = [{
193
- $global `` custom<TokenOrdering>($consumeTokens, type($produceToken)) ` :` type($result) attr-dict
192
+ $global `:` type($result) attr-dict
194
193
}];
195
194
196
195
let extraClassDeclaration = [{
@@ -238,6 +237,52 @@ def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
238
237
}];
239
238
}
240
239
240
+ //===----------------------------------------------------------------------===//
241
+ // GlobalLoadGraphOp
242
+ //===----------------------------------------------------------------------===//
243
+
244
+ def MLProgram_GlobalLoadGraphOp : MLProgram_Op<"global_load_graph", [
245
+ DeclareOpInterfaceMethods<SymbolUserOpInterface>
246
+ ]> {
247
+ let summary = "Direct load of a mutable value from a global in Graph region";
248
+ let description = [{
249
+ Performs a non-atomic, non-volatile, non-synchronized load from a global
250
+ that may be mutable.
251
+
252
+ It is fully expected that these constraints are not suitable for all
253
+ situations, and alternative ops should be defined and used for more advanced
254
+ cases.
255
+
256
+ This op is side effecting and may not be valid to use in graph regions
257
+ without additional consideration to evaluation order constraints.
258
+
259
+ Example:
260
+
261
+ ```mlir
262
+ %0, %cstr = ml_program.global_load_graph @foobar
263
+ ordering (%token -> !ml_program.token) : tensor<?xi32>
264
+ ```
265
+ }];
266
+
267
+ let arguments = (ins
268
+ Arg<SymbolRefAttr, "", [MemRead]>:$global,
269
+ Variadic<MLProgram_TokenType>:$consumeTokens
270
+ );
271
+ let results = (outs
272
+ AnyType:$result,
273
+ MLProgram_TokenType:$produceToken
274
+ );
275
+
276
+ let assemblyFormat = [{
277
+ $global `` custom<TokenOrdering>($consumeTokens, type($produceToken)) `:` type($result) attr-dict
278
+ }];
279
+
280
+ let extraClassDeclaration = [{
281
+ /// Gets the corresponding GlobalOp (or nullptr).
282
+ GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
283
+ }];
284
+ }
285
+
241
286
//===----------------------------------------------------------------------===//
242
287
// GlobalStoreOp
243
288
//===----------------------------------------------------------------------===//
@@ -255,7 +300,8 @@ def MLProgram_GlobalStoreOp : MLProgram_Op<"global_store", [
255
300
advanced cases.
256
301
257
302
This op is side effecting and may not be valid to use in graph regions
258
- without additional consideration to evaluation order constraints.
303
+ without additional consideration to evaluation order constraints. See
304
+ `global_store_graph` for op which allows for explicit ordering constraints.
259
305
260
306
Example:
261
307
@@ -266,11 +312,53 @@ def MLProgram_GlobalStoreOp : MLProgram_Op<"global_store", [
266
312
267
313
let arguments = (ins
268
314
Arg<SymbolRefAttr, "", [MemWrite]>:$global,
315
+ AnyType:$value
316
+ );
317
+
318
+ let assemblyFormat = [{
319
+ $global `=` $value `:` type($value) attr-dict
320
+ }];
321
+
322
+ let extraClassDeclaration = [{
323
+ /// Gets the corresponding GlobalOp (or nullptr).
324
+ GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
325
+ }];
326
+ }
327
+
328
+ //===----------------------------------------------------------------------===//
329
+ // GlobalStoreGraphOp
330
+ //===----------------------------------------------------------------------===//
331
+
332
+ def MLProgram_GlobalStoreGraphOp : MLProgram_Op<"global_store_graph", [
333
+ DeclareOpInterfaceMethods<SymbolUserOpInterface>
334
+ ]> {
335
+ let summary = "Direct store of a value into a mutable global";
336
+ let description = [{
337
+ Performs a non-atomic, non-volatile, non-synchronized store to a mutable
338
+ global.
339
+
340
+ It is fully expected that these constraints are not suitable for
341
+ all situations, and alternative ops should be defined and used for more
342
+ advanced cases.
343
+
344
+ This op is side effecting and may not be valid to use in graph regions
345
+ without additional consideration to evaluation order constraints.
346
+
347
+ Example:
348
+
349
+ ```mlir
350
+ %token = ml_program.global_store @foobar = %0 : tensor<?xi32>
351
+ ordering (%in_token -> !ml_program.token) : tensor<?xi32>
352
+ ```
353
+ }];
354
+
355
+ let arguments = (ins
356
+ Arg<SymbolRefAttr, "", [MemRead]>:$global,
269
357
AnyType:$value,
270
358
Variadic<MLProgram_TokenType>:$consumeTokens
271
359
);
272
360
let results = (outs
273
- Optional< MLProgram_TokenType> :$produceToken
361
+ MLProgram_TokenType:$produceToken
274
362
);
275
363
276
364
let assemblyFormat = [{
0 commit comments