-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onnx] lowering round, fix pad op, support more layernorm pattern (#491)
- Loading branch information
Showing
6 changed files
with
158 additions
and
3 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
25 changes: 25 additions & 0 deletions
25
frontends/onnx-frontend/third_party/patches/OnnxMlirOnnxOpsTensorPad.patch
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,25 @@ | ||
diff --git a/src/Dialect/ONNX/ONNXOps/Tensor/Pad.cpp b/src/Dialect/ONNX/ONNXOps/Tensor/Pad.cpp | ||
index b00edc4a..4454ee76 100644 | ||
--- a/src/Dialect/ONNX/ONNXOps/Tensor/Pad.cpp | ||
+++ b/src/Dialect/ONNX/ONNXOps/Tensor/Pad.cpp | ||
@@ -45,9 +45,17 @@ LogicalResult ONNXPadOpShapeHelper::computeShape() { | ||
// Calculate output dimension sizes. | ||
for (uint64_t i = 0; i < dataRank; i++) { | ||
// Get begin/end pads. | ||
- SymbolIndexExpr padBegin(createIE->getIntFromArrayAsSymbol(padsOperand, i)); | ||
- SymbolIndexExpr padEnd( | ||
- createIE->getIntFromArrayAsSymbol(padsOperand, i + dataRank)); | ||
+ auto padBeginIE = createIE->getIntFromArrayAsSymbol(padsOperand, i); | ||
+ if (padBeginIE.isUndefined()) { | ||
+ return failure(); | ||
+ } | ||
+ SymbolIndexExpr padBegin(padBeginIE); | ||
+ auto padEndIE = | ||
+ createIE->getIntFromArrayAsSymbol(padsOperand, i + dataRank); | ||
+ if (padEndIE.isUndefined()) { | ||
+ return failure(); | ||
+ } | ||
+ SymbolIndexExpr padEnd(padEndIE); | ||
if (padBegin.isUndefined() || padEnd.isUndefined()) | ||
return op->emitError("pad parameter could not be processed"); | ||
// Get input dim. |