@@ -26,4 +26,33 @@ using namespace mlir::torch::onnx_c;
2626// results in a lot of ONNX test cases that all reduce to the exact same
2727// thing here, so we simplify.
2828void mlir::torch::onnx_c::populateDefaultDomainQtoZ (
29- OnnxCustomOpConversionPattern &patterns) {}
29+ OnnxCustomOpConversionPattern &patterns) {
30+
31+ patterns.onOp (
32+ " Selu" , 6 , [](OpBinder binder, ConversionPatternRewriter &rewriter) {
33+ Torch::ValueTensorType resultType;
34+ float alpha, gamma;
35+ Value operand;
36+ if (binder.tensorOperand (operand) ||
37+ binder.f32FloatAttr (alpha, " alpha" ) ||
38+ binder.f32FloatAttr (gamma, " gamma" ) ||
39+ binder.tensorResultType (resultType))
40+ return failure ();
41+
42+ Value vAlpha = rewriter.create <Torch::ConstantFloatOp>(
43+ binder.getLoc (), rewriter.getType <Torch::FloatType>(),
44+ rewriter.getFloatAttr (rewriter.getF64Type (), alpha));
45+
46+ Value vScale = rewriter.create <Torch::ConstantFloatOp>(
47+ binder.getLoc (), rewriter.getType <Torch::FloatType>(),
48+ rewriter.getFloatAttr (rewriter.getF64Type (), gamma));
49+
50+ Value vInputScale = rewriter.create <Torch::ConstantFloatOp>(
51+ binder.getLoc (), rewriter.getType <Torch::FloatType>(),
52+ rewriter.getFloatAttr (rewriter.getF64Type (), 1.0 ));
53+
54+ rewriter.replaceOpWithNewOp <Torch::AtenEluOp>(
55+ binder.op , resultType, operand, vAlpha, vScale, vInputScale);
56+ return success ();
57+ });
58+ }
0 commit comments