Skip to content

Commit 93a6b49

Browse files
committed
[mlir][python] provide bindings for ops from the sparse_tensor dialect
Previously, the dialect was exposed for linking and pass management purposes, but we did not generate op classes for it. Generate them. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D110819
1 parent f9aa862 commit 93a6b49

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

mlir/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ declare_mlir_dialect_python_bindings(
128128
declare_mlir_dialect_python_bindings(
129129
ADD_TO_PARENT MLIRPythonSources.Dialects
130130
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
131+
TD_FILE dialects/SparseTensorOps.td
131132
SOURCES dialects/sparse_tensor.py
132133
DIALECT_NAME sparse_tensor)
133134

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===-- SparseTensorOps.td - Entry point for bindings ------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef PYTHON_BINDINGS_SPARSE_TENSOR_OPS
10+
#define PYTHON_BINDINGS_SPARSE_TENSOR_OPS
11+
12+
include "mlir/Bindings/Python/Attributes.td"
13+
include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.td"
14+
15+
#endif

mlir/python/mlir/dialects/sparse_tensor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5+
from ._sparse_tensor_ops_gen import *
56
from .._mlir_libs._mlir.dialects.sparse_tensor import *
67
from .._mlir_libs import _mlirSparseTensorPasses as _cextSparseTensorPasses

0 commit comments

Comments
 (0)