2020-02-25 23:38:08 +08:00
|
|
|
//===----- identity.cpp - Lowering Identity Op ----------------------------===//
|
2020-02-19 15:17:48 +08:00
|
|
|
//
|
|
|
|
// Copyright 2019 The IBM Research Authors.
|
|
|
|
//
|
|
|
|
// =============================================================================
|
|
|
|
//
|
|
|
|
// This file lowers the ONNX Identity Operator to Krnl dialect.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-02-25 23:38:08 +08:00
|
|
|
#include "src/conversion/onnx_to_krnl/onnx_to_krnl_common.hpp"
|
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
|
2020-02-19 15:17:48 +08:00
|
|
|
struct ONNXIdentityOpLowering : public ConversionPattern {
|
|
|
|
ONNXIdentityOpLowering(MLIRContext *ctx)
|
|
|
|
: ConversionPattern(mlir::ONNXIdentityOp::getOperationName(), 1, ctx) {}
|
|
|
|
|
|
|
|
PatternMatchResult
|
|
|
|
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
|
|
|
ConversionPatternRewriter &rewriter) const final {
|
|
|
|
rewriter.replaceOp(op, operands[0]);
|
|
|
|
return matchSuccess();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void populateLoweringONNXIdentityOpPattern(
|
|
|
|
OwningRewritePatternList &patterns, MLIRContext *ctx) {
|
|
|
|
patterns.insert<ONNXIdentityOpLowering>(ctx);
|
|
|
|
}
|