mirror of https://github.com/llvm/torch-mlir
Add a sample test that exercises short circuit control flow.
parent
b811db4b76
commit
b3ecd57b29
|
@ -27,3 +27,11 @@ def int_add(a: int, b: int):
|
|||
|
||||
result = int_add(5, 6)
|
||||
assert result == 11
|
||||
|
||||
|
||||
@compile_function
|
||||
def simple_control_flow(a: int, b: int):
|
||||
return (a * b) and (a - b)
|
||||
|
||||
assert simple_control_flow(5, 6) == -1
|
||||
assert simple_control_flow(-1, 0) == 0
|
||||
|
|
|
@ -10,6 +10,13 @@ __all__ = [
|
|||
"CompilerBackend",
|
||||
]
|
||||
|
||||
FRONTEND_PASSES = (
|
||||
"basicpy-type-inference",
|
||||
"convert-basicpy-to-std",
|
||||
"canonicalize",
|
||||
"convert-scf-to-std",
|
||||
)
|
||||
|
||||
_ireec = None
|
||||
_ireert = None
|
||||
_cached_config = None
|
||||
|
@ -111,8 +118,7 @@ class CompilerBackend:
|
|||
backend compilation. They are separated to aid debugging.
|
||||
"""
|
||||
# TOOD: Have an API for this
|
||||
pm.addPassPipelines("basicpy-type-inference", "convert-basicpy-to-std",
|
||||
"canonicalize")
|
||||
pm.addPassPipelines(*FRONTEND_PASSES)
|
||||
|
||||
def add_backend_passes(self, pm: mlir.passes.PassManager):
|
||||
"""Adds passes for full backend compilation.
|
||||
|
|
Loading…
Reference in New Issue