Skip to content

Commit

Permalink
Merge pull request #284 from Xilinx/rogarcia.fix_layerNorm_recomposition
Browse files Browse the repository at this point in the history
Fix LayerNorm recomposition by properly using provided epsilon value
  • Loading branch information
roberteg16 authored Feb 5, 2025
2 parents a96118c + 5051f97 commit f4d1ac4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
4 changes: 3 additions & 1 deletion src/Dialect/ONNX/Transforms/Recompose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ struct RecomposeLayerNormFromMulPattern : public OpRewritePattern<ONNXMulOp> {
mlir::dyn_cast<ONNXConstantOp>(epsilon.getDefiningOp());
if (!epsilonOp)
return reportFailure("RMS epsilon needs to be a constant");
epsilonAttr = epsilonOp.getValueFloatAttr();
const auto epsilonValue = getScalarValue<double>(epsilonOp);
epsilonAttr =
FloatAttr::get(Float32Type::get(epsilonOp->getContext()), epsilonValue);
// Check axes.
if (!hasShapeAndRank(dd))
return reportFailure("RMS need rank and shape for input dd");
Expand Down
Loading

0 comments on commit f4d1ac4

Please sign in to comment.