This commit moves FuncOp out of the builtin dialect, and into the Func dialect. This move has been planned in some capacity from the moment we made FuncOp an operation (years ago). This commit handles the functional aspects of the move, but various aspects are left untouched to ease migration: func::FuncOp is re-exported into mlir to reduce the actual API churn, the assembly format still accepts the unqualified `func`. These temporary measures will remain for a little while to simplify migration before being removed. Differential Revision: https://reviews.llvm.org/D121266
30 lines
807 B
Python
30 lines
807 B
Python
# RUN: %PYTHON %s | FileCheck %s
|
|
|
|
# Naming this file with a `_dialect` suffix to avoid a naming conflict with
|
|
# python package's math module (coming in from random.py).
|
|
|
|
from mlir.ir import *
|
|
import mlir.dialects.func as func
|
|
import mlir.dialects.math as mlir_math
|
|
|
|
def run(f):
|
|
print("\nTEST:", f.__name__)
|
|
f()
|
|
|
|
# CHECK-LABEL: TEST: testMathOps
|
|
@run
|
|
def testMathOps():
|
|
with Context() as ctx, Location.unknown():
|
|
module = Module.create()
|
|
with InsertionPoint(module.body):
|
|
@func.FuncOp.from_py_func(F32Type.get())
|
|
def emit_sqrt(arg):
|
|
return mlir_math.SqrtOp(arg)
|
|
|
|
# CHECK-LABEL: func @emit_sqrt(
|
|
# CHECK-SAME: %[[ARG:.*]]: f32) -> f32 {
|
|
# CHECK: math.sqrt %[[ARG]] : f32
|
|
# CHECK: return
|
|
# CHECK: }
|
|
print(module)
|