diff --git a/mlir/python/mlir/dialects/CMakeLists.txt b/mlir/python/mlir/dialects/CMakeLists.txt --- a/mlir/python/mlir/dialects/CMakeLists.txt +++ b/mlir/python/mlir/dialects/CMakeLists.txt @@ -45,6 +45,11 @@ DIALECT_NAME tensor) add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonTensorOps) +add_mlir_dialect_python_bindings(MLIRBindingsPythonVectorOps + TD_FILE VectorOps.td + DIALECT_NAME vector) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonVectorOps) + ################################################################################ # Installation. ################################################################################ diff --git a/mlir/python/mlir/dialects/VectorOps.td b/mlir/python/mlir/dialects/VectorOps.td new file mode 100644 --- /dev/null +++ b/mlir/python/mlir/dialects/VectorOps.td @@ -0,0 +1,15 @@ +//===-- MemRefOps.td - Entry point for MemRefOps bind ------*- tablegen -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef PYTHON_BINDINGS_VECTOR_OPS +#define PYTHON_BINDINGS_VECTOR_OPS + +include "mlir/Bindings/Python/Attributes.td" +include "mlir/Dialect/Vector/VectorOps.td" + +#endif diff --git a/mlir/python/mlir/dialects/vector.py b/mlir/python/mlir/dialects/vector.py new file mode 100644 --- /dev/null +++ b/mlir/python/mlir/dialects/vector.py @@ -0,0 +1,5 @@ +# 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 ._vector_ops_gen import * diff --git a/mlir/test/python/dialects/vector.py b/mlir/test/python/dialects/vector.py new file mode 100644 --- /dev/null +++ b/mlir/test/python/dialects/vector.py @@ -0,0 +1,26 @@ +# RUN: %PYTHON %s | FileCheck %s + +from mlir.ir import * +import mlir.dialects.builtin as builtin +import mlir.dialects.vector as vector + +def run(f): + print("\nTEST:", f.__name__) + f() + +# CHECK-LABEL: TEST: testPrintOp +@run +def testPrintOp(): + with Context() as ctx, Location.unknown(): + module = Module.create() + with InsertionPoint(module.body): + @builtin.FuncOp.from_py_func(VectorType.get((12, 5), F32Type.get())) + def print_vector(arg): + return vector.PrintOp(arg) + + # CHECK-LABEL: func @print_vector( + # CHECK-SAME: %[[ARG:.*]]: vector<12x5xf32>) { + # CHECK: vector.print %[[ARG]] : vector<12x5xf32> + # CHECK: return + # CHECK: } + print(module)