blob: bdec43825ddc2544bfd29d3367ad2d652294194a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//===- SparseTensorTransformOps.cpp - sparse tensor transform ops impl ----===//
//
// 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/TransformOps/SparseTensorTransformOps.h"
#include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
using namespace mlir;
using namespace mlir::sparse_tensor;
//===----------------------------------------------------------------------===//
// Transform op implementation
//===----------------------------------------------------------------------===//
DiagnosedSilenceableFailure transform::MatchSparseInOut::matchOperation(
mlir::Operation *current, mlir::transform::TransformResults &results,
mlir::transform::TransformState &state) {
bool hasSparseInOut = hasAnySparseOperandOrResult(current);
if (!hasSparseInOut) {
return emitSilenceableFailure(current->getLoc(),
"operation has no sparse input or output");
}
results.set(cast<OpResult>(getResult()), state.getPayloadOps(getTarget()));
return DiagnosedSilenceableFailure::success();
}
//===----------------------------------------------------------------------===//
// Transform op registration
//===----------------------------------------------------------------------===//
namespace {
class SparseTensorTransformDialectExtension
: public transform::TransformDialectExtension<
SparseTensorTransformDialectExtension> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
SparseTensorTransformDialectExtension)
SparseTensorTransformDialectExtension() {
declareGeneratedDialect<sparse_tensor::SparseTensorDialect>();
registerTransformOps<
#define GET_OP_LIST
#include "mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp.inc"
>();
}
};
} // namespace
#define GET_OP_CLASSES
#include "mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp.inc"
void mlir::sparse_tensor::registerTransformDialectExtension(
DialectRegistry ®istry) {
registry.addExtensions<SparseTensorTransformDialectExtension>();
}
|