Skip to content

Commit b740597

Browse files
committed
[MLIR][AMDGPU] Use Attr for resetOffset + boundsCheck in RawBufferCastOp
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 354944d commit b740597

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ 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)> {
243243
let summary = "Create a raw buffer fat pointer that matches `memref`";
244244
let description = [{

mlir/test/python/dialects/amdgpu.py

Lines changed: 26 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,28 @@ 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(
33+
"test_raw_buffer_cast_params", ([memref_type], [])
34+
)
35+
with InsertionPoint(f.add_entry_block()):
36+
block_args = f.arguments
37+
amdgpu.FatRawBufferCastOp(block_args[0])
38+
amdgpu.FatRawBufferCastOp(block_args[0], resetOffset=True)
39+
amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False)
40+
amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False, resetOffset=True)
41+
func.ReturnOp([])
42+
43+
#CHECK: func.func @test_raw_buffer_cast_params(%[[ARG0:.+]]: memref<?x?xf32>) {
44+
#CHECK: amdgpu.fat_raw_buffer_cast %[[ARG0]] : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
45+
#CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] resetOffset : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
46+
#CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] boundsCheck(false) : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>>
47+
#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)