-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into philippb.refactor_torch_to_tosa
- Loading branch information
Showing
28 changed files
with
1,089 additions
and
657 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,55 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//===---------------- Concat.cpp - Lowering Concat Op -------------------===// | ||
// | ||
// Copyright 2019-2022 The IBM Research Authors. | ||
// | ||
// ============================================================================= | ||
// | ||
// This file lowers the ONNX Print Signature Operator to Krnl dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp" | ||
#include "src/Dialect/Krnl/KrnlHelper.hpp" | ||
#include "src/Dialect/ONNX/ShapeInference/ONNXShapeHelper.hpp" | ||
|
||
using namespace mlir; | ||
|
||
namespace onnx_mlir { | ||
|
||
struct ONNXPrintSignatureLowering : public ConversionPattern { | ||
ONNXPrintSignatureLowering(TypeConverter &typeConverter, MLIRContext *ctx) | ||
: ConversionPattern( | ||
typeConverter, ONNXPrintSignatureOp::getOperationName(), 1, ctx) {} | ||
|
||
LogicalResult matchAndRewrite(Operation *op, ArrayRef<Value> operands, | ||
ConversionPatternRewriter &rewriter) const final { | ||
// Gather info. | ||
auto loc = op->getLoc(); | ||
MultiDialectBuilder<KrnlBuilder> create(rewriter, loc); | ||
ONNXPrintSignatureOp printSignatureOp = | ||
llvm::dyn_cast<ONNXPrintSignatureOp>(op); | ||
ONNXPrintSignatureOpAdaptor operandAdaptor(operands); | ||
|
||
std::string opName(printSignatureOp.op_name().data()); | ||
std::string msg = opName; | ||
create.krnl.printf(msg); | ||
for (Value oper : operandAdaptor.input()) { | ||
msg = "%t "; | ||
create.krnl.printTensor(msg, oper); | ||
} | ||
Value noneValue; | ||
rewriter.replaceOpWithNewOp<KrnlPrintOp>(op, "\n", noneValue); | ||
return success(); | ||
} | ||
}; | ||
|
||
void populateLoweringONNXPrintSignaturePattern(RewritePatternSet &patterns, | ||
TypeConverter &typeConverter, MLIRContext *ctx) { | ||
patterns.insert<ONNXPrintSignatureLowering>(typeConverter, ctx); | ||
} | ||
|
||
} // namespace onnx_mlir |
Oops, something went wrong.