Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][sparse] migrate sparse operations into new sparse tensor dialect
This is the very first step toward removing the glue and clutter from linalg and replace it with proper sparse tensor types. This revision migrates the LinalgSparseOps into SparseTensorOps of a sparse tensor dialect. This also provides a new home for sparse tensor related transformation. NOTE: the actual replacement with sparse tensor types (and removal of linalg glue/clutter) will follow but I am trying to keep the amount of changes per revision manageable. Differential Revision: https://reviews.llvm.org/D101573
- Loading branch information
Showing
38 changed files
with
459 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_mlir_dialect(SparseTensorOps sparse_tensor) | ||
add_mlir_doc(SparseTensorOps SparseTensorOps Dialects/ -gen-dialect-doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===- SparseTensor.h - Sparse tensor dialect -------------------*- C++ -*-===// | ||
// | ||
// 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 MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ | ||
#define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ | ||
|
||
#include "mlir/IR/BuiltinTypes.h" | ||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc" | ||
|
||
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc" | ||
|
||
#endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ |
29 changes: 29 additions & 0 deletions
29
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorBase.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- SparseTensorBase.td - Sparse tensor dialect base ----*- 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 SPARSETENSOR_BASE | ||
#define SPARSETENSOR_BASE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def SparseTensor_Dialect : Dialect { | ||
let name = "sparse_tensor"; | ||
let cppNamespace = "::mlir::sparse_tensor"; | ||
let description = [{ | ||
The `sparse tensor` dialect is intended to hold primitives that | ||
form a bridge between high-level operations on sparse tensors | ||
and lower-level operations on the actual sparse storage schemes | ||
consisting of pointers, indices, and values. This bridge | ||
simplifies a `sparse compiler` pass by postponing actual | ||
code generation for the supported primitives to a later phase, | ||
either by generating calls into a runtime support library | ||
or by further lowering the primitives into actual code. | ||
}]; | ||
} | ||
|
||
#endif // SPARSETENSOR_BASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
mlir/include/mlir/Dialect/SparseTensor/Transforms/Transforms.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===- Transforms.h - Sparse tensor transformations -------------*- C++ -*-===// | ||
// | ||
// 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 MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_TRANSFORMS_H_ | ||
#define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_TRANSFORMS_H_ | ||
|
||
#include "mlir/IR/PatternMatch.h" | ||
|
||
namespace mlir { | ||
namespace sparse_tensor { | ||
|
||
/// Sets up sparsification conversion rules with the given options. | ||
void populateSparsificationConversionPatterns(RewritePatternSet &patterns); | ||
|
||
} // namespace sparse_tensor | ||
} // namespace mlir | ||
|
||
#endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_TRANSFORMS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_subdirectory(IR) | ||
add_subdirectory(Transforms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
add_mlir_dialect_library(MLIRSparseTensor | ||
SparseTensorDialect.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SparseTensor | ||
|
||
DEPENDS | ||
MLIRSparseTensorOpsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRDialect | ||
MLIRIR | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===- SparseTensorDialect.cpp - Sparse tensor dialect implementation -----===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" | ||
|
||
#include "mlir/IR/Builders.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::sparse_tensor; | ||
|
||
void SparseTensorDialect::initialize() { | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc" | ||
>(); | ||
} | ||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc" |
Oops, something went wrong.