Files
clang-p2996/mlir/test/python/dialects/ml_program.py
Tobias Hieta f9008e6366 [NFC][Py Reformat] Reformat python files in mlir subdir
This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential Revision: https://reviews.llvm.org/D150782
2023-05-26 08:05:40 +02:00

29 lines
790 B
Python

# RUN: %PYTHON %s | FileCheck %s
# This is just a smoke test that the dialect is functional.
from mlir.ir import *
from mlir.dialects import ml_program
def constructAndPrintInModule(f):
print("\nTEST:", f.__name__)
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
f()
print(module)
return f
# CHECK-LABEL: testFuncOp
@constructAndPrintInModule
def testFuncOp():
# CHECK: ml_program.func @foobar(%arg0: si32) -> si32
f = ml_program.FuncOp(
name="foobar", type=([IntegerType.get_signed(32)], [IntegerType.get_signed(32)])
)
block = f.add_entry_block()
with InsertionPoint(block):
# CHECK: ml_program.return
ml_program.ReturnOp([block.arguments[0]])