diff options
Diffstat (limited to 'mlir/test/python')
-rw-r--r-- | mlir/test/python/dialects/amdgpu.py | 25 | ||||
-rw-r--r-- | mlir/test/python/ir/array_attributes.py | 22 | ||||
-rw-r--r-- | mlir/test/python/ir/operation.py | 4 |
3 files changed, 48 insertions, 3 deletions
diff --git a/mlir/test/python/dialects/amdgpu.py b/mlir/test/python/dialects/amdgpu.py index c8039d4..b479576 100644 --- a/mlir/test/python/dialects/amdgpu.py +++ b/mlir/test/python/dialects/amdgpu.py @@ -2,7 +2,7 @@ # This is just a smoke test that the dialect is functional. from mlir.ir import * -from mlir.dialects import amdgpu, arith, memref +from mlir.dialects import amdgpu, func def constructAndPrintInModule(f): @@ -20,3 +20,26 @@ def constructAndPrintInModule(f): def testSmoke(): # CHECK: amdgpu.lds_barrier amdgpu.LDSBarrierOp() + + +# CHECK-LABEL: testFatRawBufferCastOpParams +@constructAndPrintInModule +def testFatRawBufferCastOpParams(): + memref_type = MemRefType.get( + [ShapedType.get_dynamic_size(), ShapedType.get_dynamic_size()], + F32Type.get(), + ) + f = func.FuncOp("test_raw_buffer_cast_params", ([memref_type], [])) + with InsertionPoint(f.add_entry_block()): + block_args = f.arguments + amdgpu.FatRawBufferCastOp(block_args[0]) + amdgpu.FatRawBufferCastOp(block_args[0], resetOffset=True) + amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False) + amdgpu.FatRawBufferCastOp(block_args[0], boundsCheck=False, resetOffset=True) + func.ReturnOp([]) + + # CHECK: func.func @test_raw_buffer_cast_params(%[[ARG0:.+]]: memref<?x?xf32>) { + # CHECK: amdgpu.fat_raw_buffer_cast %[[ARG0]] : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>> + # CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] resetOffset : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>> + # CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] boundsCheck(false) : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>> + # CHECK-NEXT: amdgpu.fat_raw_buffer_cast %[[ARG0]] boundsCheck(false) resetOffset : memref<?x?xf32> to memref<?x?xf32, #amdgpu.address_space<fat_raw_buffer>> diff --git a/mlir/test/python/ir/array_attributes.py b/mlir/test/python/ir/array_attributes.py index ef1d835..66f7ec8 100644 --- a/mlir/test/python/ir/array_attributes.py +++ b/mlir/test/python/ir/array_attributes.py @@ -31,6 +31,7 @@ def testGetDenseElementsUnsupported(): # CHECK: unimplemented array format conversion from format: print(e) + # CHECK-LABEL: TEST: testGetDenseElementsUnSupportedTypeOkIfExplicitTypeProvided @run def testGetDenseElementsUnSupportedTypeOkIfExplicitTypeProvided(): @@ -41,8 +42,9 @@ def testGetDenseElementsUnSupportedTypeOkIfExplicitTypeProvided(): # realistic example would be a NumPy extension type like the bfloat16 # type from the ml_dtypes package, which isn't a dependency of this # test. - attr = DenseElementsAttr.get(array.view(np.datetime64), - type=IntegerType.get_signless(64)) + attr = DenseElementsAttr.get( + array.view(np.datetime64), type=IntegerType.get_signless(64) + ) # CHECK: dense<{{\[}}[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi64> print(attr) # CHECK: {{\[}}[1 2 3] @@ -135,6 +137,7 @@ def testGetDenseElementsFromListMixedTypes(): # Splats. ################################################################################ + # CHECK-LABEL: TEST: testGetDenseElementsSplatInt @run def testGetDenseElementsSplatInt(): @@ -617,3 +620,18 @@ def testGetDenseResourceElementsAttr(): # CHECK: BACKING MEMORY DELETED # CHECK: EXIT FUNCTION print("EXIT FUNCTION") + + +# CHECK-LABEL: TEST: testDanglingResource +print("TEST: testDanglingResource") +# see https://github.com/llvm/llvm-project/pull/149414, https://github.com/llvm/llvm-project/pull/150137, https://github.com/llvm/llvm-project/pull/150561 +# This error occurs only when there is an alive context with a DenseResourceElementsAttr +# in the end of the program, so we put it here without an encapsulating function. +ctx = Context() + +with ctx, Location.unknown(): + DenseResourceElementsAttr.get_from_buffer( + memoryview(np.array([1, 2, 3])), + "some_resource", + RankedTensorType.get((3,), IntegerType.get_signed(32)), + ) diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py index ede1571..c6b5daf 100644 --- a/mlir/test/python/ir/operation.py +++ b/mlir/test/python/ir/operation.py @@ -978,8 +978,12 @@ def testModuleMerge(): foo = m1.body.operations[0] bar = m2.body.operations[0] qux = m2.body.operations[1] + assert bar.is_before_in_block(qux) bar.move_before(foo) + assert bar.is_before_in_block(foo) qux.move_after(foo) + assert bar.is_before_in_block(qux) + assert foo.is_before_in_block(qux) # CHECK: module # CHECK: func private @bar |