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