2020-03-19 16:48:09 +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-03-19 16:48:09 +08:00
|
|
|
#include "src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp"
|
2020-02-25 23:38:08 +08:00
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
|
2020-02-19 15:17:48 +08:00
|
|
|
struct ONNXIdentityOpLowering : public ConversionPattern {
|
|
|
|
ONNXIdentityOpLowering(MLIRContext *ctx)
|
|
|
|
: ConversionPattern(mlir::ONNXIdentityOp::getOperationName(), 1, ctx) {}
|
|
|
|
|
2020-04-02 00:38:34 +08:00
|
|
|
LogicalResult matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
2020-03-31 23:55:27 +08:00
|
|
|
ConversionPatternRewriter &rewriter) const final {
|
|
|
|
ONNXIdentityOpOperandAdaptor operandAdaptor(operands);
|
|
|
|
rewriter.replaceOp(op, operandAdaptor.input());
|
2020-04-02 00:38:34 +08:00
|
|
|
return success();
|
2020-02-19 15:17:48 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void populateLoweringONNXIdentityOpPattern(
|
|
|
|
OwningRewritePatternList &patterns, MLIRContext *ctx) {
|
|
|
|
patterns.insert<ONNXIdentityOpLowering>(ctx);
|
|
|
|
}
|