1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# RUN: %PYTHON %s | FileCheck %s
from mlir.ir import *
from mlir.dialects import transform
from mlir.dialects.transform import gpu
def run(f):
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
print("\nTEST:", f.__name__)
f()
print(module)
return f
@run
def testMapForallToBlocksCompact():
sequence = transform.SequenceOp(
transform.FailurePropagationMode.PROPAGATE, [], transform.AnyOpType.get()
)
with InsertionPoint(sequence.body):
gpu.MapForallToBlocks(sequence.bodyTarget)
transform.YieldOp()
# CHECK-LABEL: TEST: testMapForallToBlocksCompact
# CHECK: = transform.gpu.map_forall_to_blocks
# CHECK-NOT: grid_dims
# CHECK-SAME: (!transform.any_op) -> !transform.any_op
# CHECK-NOT: grid_dims
@run
def testMapForallToBlocksTyped():
sequence = transform.SequenceOp(
transform.FailurePropagationMode.PROPAGATE, [], transform.AnyOpType.get()
)
with InsertionPoint(sequence.body):
gpu.MapForallToBlocks(
transform.OperationType.get("test.dummy"), sequence.bodyTarget
)
transform.YieldOp()
# CHECK-LABEL: TEST: testMapForallToBlocksTyped
# CHECK: = transform.gpu.map_forall_to_blocks
# CHECK-SAME: (!transform.any_op) -> !transform.op<"test.dummy">
@run
def testMapForallToBlocksGridDims():
sequence = transform.SequenceOp(
transform.FailurePropagationMode.PROPAGATE, [], transform.AnyOpType.get()
)
with InsertionPoint(sequence.body):
gpu.MapForallToBlocks(sequence.bodyTarget, grid_dims=[4, 2])
transform.YieldOp()
# CHECK-LABEL: TEST: testMapForallToBlocksGridDims
# CHECK: = transform.gpu.map_forall_to_blocks
# CHECK-SAME: grid_dims = [4, 2]
# CHECK-SAME: (!transform.any_op) -> !transform.any_op
|