mirror of https://github.com/llvm/torch-mlir
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "npcomp/Conversion/TCFToTCP/TCFToTCP.h"
|
|
|
|
#include "../PassDetail.h"
|
|
#include "mlir/Dialect/Shape/IR/Shape.h"
|
|
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
|
#include "mlir/Dialect/Traits.h"
|
|
#include "mlir/Transforms/DialectConversion.h"
|
|
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
|
|
#include "npcomp/Dialect/TCF/IR/TCFOps.h"
|
|
#include "npcomp/Dialect/TCP/IR/TCPDialect.h"
|
|
#include "npcomp/Dialect/TCP/IR/TCPOps.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::NPCOMP;
|
|
|
|
namespace {
|
|
class ConvertTCFToTCP : public ConvertTCFToTCPBase<ConvertTCFToTCP> {
|
|
public:
|
|
void getDependentDialects(DialectRegistry ®istry) const override {
|
|
registry.insert<shape::ShapeDialect, tcp::TCPDialect>();
|
|
}
|
|
|
|
void runOnOperation() override {
|
|
(void)applyPatternsAndFoldGreedily(getOperation(), getPatterns());
|
|
}
|
|
|
|
FrozenRewritePatternList getPatterns() {
|
|
// NOTE: We are keeping this pass around, even though it currently does
|
|
// nothing, in order to avoid having to reintroduce the same
|
|
// boilerplate.
|
|
OwningRewritePatternList patterns;
|
|
return std::move(patterns);
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
std::unique_ptr<OperationPass<FuncOp>>
|
|
mlir::NPCOMP::createConvertTCFToTCPPass() {
|
|
return std::make_unique<ConvertTCFToTCP>();
|
|
}
|