from mlir.ir import *
import mlir.dialects.gpu as gpu
import mlir.dialects.gpu.passes
from mlir.passmanager import *
def run(f):
print("\nTEST:", f.__name__)
with Context(), Location.unknown():
f()
return f
@run
def testGPUPass():
PassManager.parse("any(gpu-kernel-outlining)")
print("SUCCESS")
@run
def testMMAElementWiseAttr():
module = Module.create()
with InsertionPoint(module.body):
gpu.BlockDimOp(gpu.Dimension.y)
print(module)
pass
@run
def testObjectAttr():
target = Attribute.parse("#nvvm.target")
format = gpu.CompilationTarget.Fatbin
object = b"BC\xc0\xde5\x14\x00\x00\x05\x00\x00\x00b\x0c0$MY\xbef"
properties = DictAttr.get({"O": IntegerAttr.get(IntegerType.get_signless(32), 2)})
o = gpu.ObjectAttr.get(target, format, object, properties)
print(o)
assert o.object == object
o = gpu.ObjectAttr.get(target, format, object)
print(o)
object = (
b"//\n// Generated by LLVM NVPTX Back-End\n//\n\n.version 6.0\n.target sm_50"
)
o = gpu.ObjectAttr.get(target, format, object)
print(o)
assert o.object == object