forked from onnx/onnx-mlir
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoBump] Merge with c5d3e72 (Sep 06)
- Loading branch information
Showing
10 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//===--------------------- Yield.cpp - Lowering Yield Op ------------------===// | ||
// | ||
// Copyright 2019-2023 The IBM Research Authors. | ||
// | ||
// ============================================================================= | ||
// | ||
// This file lowers the ONNX Yield Operator to Krnl dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Dialect/SCF/IR/SCF.h" | ||
|
||
#include "src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp" | ||
|
||
using namespace mlir; | ||
|
||
namespace onnx_mlir { | ||
|
||
struct ONNXYieldOpLowering : public OpConversionPattern<ONNXYieldOp> { | ||
ONNXYieldOpLowering(TypeConverter &typeConverter, MLIRContext *ctx) | ||
: OpConversionPattern(typeConverter, ctx) {} | ||
|
||
LogicalResult matchAndRewrite(ONNXYieldOp yieldOp, ONNXYieldOpAdaptor adaptor, | ||
ConversionPatternRewriter &rewriter) const final { | ||
// Gather info. | ||
Operation *op = yieldOp.getOperation(); | ||
Location loc = ONNXLoc<ONNXYieldOp>(op); | ||
|
||
MultiDialectBuilder<KrnlBuilder, MathBuilder, MemRefBuilder> create( | ||
rewriter, loc); | ||
|
||
ValueRange inputs = yieldOp.getOperands(); | ||
llvm::SmallVector<Value> outputs; | ||
for (Value input : inputs) { | ||
Type inputType = input.getType(); | ||
Type outputType = typeConverter->convertType(inputType); | ||
outputs.emplace_back(typeConverter->materializeTargetConversion( | ||
rewriter, loc, outputType, input)); | ||
} | ||
|
||
rewriter.replaceOpWithNewOp<scf::YieldOp>(yieldOp, outputs); | ||
|
||
onnxToKrnlSimdReport(op); | ||
return success(); | ||
} | ||
}; | ||
|
||
void populateLoweringONNXYieldOpPattern(RewritePatternSet &patterns, | ||
TypeConverter &typeConverter, MLIRContext *ctx) { | ||
patterns.insert<ONNXYieldOpLowering>(typeConverter, ctx); | ||
} | ||
|
||
} // namespace onnx_mlir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.