torch-mlir/python/samples/ast_extraction.py

21 lines
462 B
Python
Raw Normal View History

2020-06-07 12:29:20 +08:00
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
from npcomp.compiler.frontend import *
2020-06-07 12:29:20 +08:00
def binary_expression():
a = 1
b = 100
c = a * b + 4
2020-06-07 13:01:38 +08:00
c = c * 2.0
2020-06-07 12:29:20 +08:00
return c
2020-06-07 12:29:20 +08:00
fe = ImportFrontend()
try:
f = fe.import_global_function(binary_expression)
finally:
print(fe.ir_module.to_asm(debug_info=True))