Skip to content

Commit 6fa759b

Browse files
authored
[MLIR][AMDGPU] Use Attr for resetOffset + boundsCheck in RawBufferCastOp (#149939)
In order to access and modify resetOffset and boundsCheck of RawBufferCastOp in pythonic binding, we will have to use Attrs instead of Property. This is because we do not have python binding support for property yet. We should move back to property once we add pythonic binding support for it. --------- Signed-off-by: Stanley Winata <[email protected]>
1 parent 46f6df0 commit 6fa759b

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPU.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ def AMDGPU_FatRawBufferCastOp :
237237
Arguments<(ins AnyMemRef:$source,
238238
Optional<I32>:$validBytes,
239239
Optional<I<14>>:$cacheSwizzleStride,
240-
DefaultValuedProp<BoolProp, "true">:$boundsCheck,
241-
UnitProp:$resetOffset)>,
240+
DefaultValuedAttr<BoolAttr, "true">:$boundsCheck,
241+
UnitAttr:$resetOffset)>,
242242
Results<(outs AnyMemRef:$result)> {
243+
// TODO: Set `resetOffset` and `boundsCheck` to use `Property` once
244+
// we implemented pythonic binding for `Property`.
243245
let summary = "Create a raw buffer fat pointer that matches `memref`";
244246
let description = [{
245247
Wraps the memory pointed to by `source` as a raw buffer fat pointer, or,

mlir/test/python/dialects/amdgpu.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This is just a smoke test that the dialect is functional.
33

44
from mlir.ir import *
5-
from mlir.dialects import amdgpu, arith, memref
5+
from mlir.dialects import amdgpu, func
66

77

88
def constructAndPrintInModule(f):
@@ -20,3 +20,26 @@ def constructAndPrintInModule(f):
2020
def testSmoke():
2121
# CHECK: amdgpu.lds_barrier
2222
amdgpu.LDSBarrierOp()
23+
24+
25+
# CHECK-LABEL: testFatRawBufferCastOpParams
26+
@constructAndPrintInModule
27+
def testFatRawBufferCastOpParams():
28+
memref_type = MemRefType.get(
29+
[ShapedType.get_dynamic_size(), ShapedType.get_dynamic_size()],
30+
F32Type.get(),
31+
)
32+
f = func.FuncOp("test_raw_buffer_cast_params", ([memref_type], []))
33+
with InsertionPoint(f.add_entry_block()):
34+
block_args = f.arguments
35+
amdgpu.FatRawBufferCastOp(block_args[0])
36+
amdgpu.FatRawBufferCastOp(block_args[0], resetOffset=True)
37+
amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False)
38+
amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False, resetOffset=True)
39+
func.ReturnOp([])
40+
41+
# CHECK: func.func @test_raw_buffer_cast_params(%[[ARG0:.+]]: memref<?x?xf32>) {
42+
# CHECK: amdgpu.fat_raw_buffer_cast %[[ARG0]] : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
43+
# CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] resetOffset : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
44+
# CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] boundsCheck(false) : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
45+
# CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] boundsCheck(false) resetOffset : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>

0 commit comments

Comments
 (0)