From b76a6d33fefa6394739972625a8e3f2eb1154e42 Mon Sep 17 00:00:00 2001 From: Tiago Trevisan Jost Date: Mon, 11 Mar 2024 21:42:22 +0100 Subject: [PATCH 1/2] feat: remve TorchToTosa legalizations that lower to tosa.custom. --- lib/Conversion/TorchToTosa/TorchToTosa.cpp | 49 ---------------------- 1 file changed, 49 deletions(-) diff --git a/lib/Conversion/TorchToTosa/TorchToTosa.cpp b/lib/Conversion/TorchToTosa/TorchToTosa.cpp index 5ddab7320c7a..b8d841dcd444 100644 --- a/lib/Conversion/TorchToTosa/TorchToTosa.cpp +++ b/lib/Conversion/TorchToTosa/TorchToTosa.cpp @@ -5687,43 +5687,6 @@ LogicalResult ConvertAtenOp::matchAndRewrite( return success(); } -template -class ConvertAtenOpToTosaCustomOp : public OpConversionPattern { -public: - using OpConversionPattern::OpConversionPattern; - using OpAdaptor = typename AtenOpT::Adaptor; - - ConvertAtenOpToTosaCustomOp(TypeConverter &typeConverter, - MLIRContext *context, std::string opName, - std::string implementedWithOpAttr = "UNDEF") - : OpConversionPattern(typeConverter, context), - opName(std::move(opName)), - implementedWithOpAttr(std::move(implementedWithOpAttr)) {} - - LogicalResult - matchAndRewrite(AtenOpT op, OpAdaptor adaptor, - ConversionPatternRewriter &rewriter) const override { - - // Set tosa.custom_op attributes. - // Only identifier needs to be known. Other attributes are not used. - auto *ctx = op->getContext(); - auto identifier = StringAttr::get(ctx, opName); - auto implementAttr = StringAttr::get(ctx, implementedWithOpAttr); - auto config = StringAttr::get(ctx, "UNDEF"); - - rewriter.replaceOpWithNewOp( - op, - TypeRange{OpConversionPattern::getTypeConverter()->convertType( - op.getType())}, - identifier, config, implementAttr, adaptor.getOperands()); - return success(); - } - -private: - std::string opName; - std::string implementedWithOpAttr; -}; - class SimplifyAtenIndexTensorWithSliceIndex : public OpRewritePattern { public: @@ -6160,18 +6123,6 @@ class ConvertTorchToTosa : public ConvertTorchToTosaBase { INSERT_CLONE_ATENOP_PATTERN(AtenCloneOp); #undef INSERT_CLONE_ATENOP_PATTERN -#define INSERT_ATEN_TO_TOSA_CUSTOMOP_PATTERN(AtenOp, opName, implementedWith) \ - target.addIllegalOp(); \ - patterns.add>(typeConverter, context, \ - opName, implementedWith); - INSERT_ATEN_TO_TOSA_CUSTOMOP_PATTERN(AtenAtan2Op, "math.atan2", - "linalg.generic"); - INSERT_ATEN_TO_TOSA_CUSTOMOP_PATTERN(AtenSinOp, "math.sin", - "linalg.generic"); - INSERT_ATEN_TO_TOSA_CUSTOMOP_PATTERN(AtenCosOp, "math.cos", - "linalg.generic"); -#undef INSERT_ATEN_TO_TOSA_CUSTOMOP_PATTERN - if (failed(applyPartialConversion(getOperation(), target, std::move(patterns)))) return signalPassFailure(); From 67d5ac165e71dc46b84788f53d9d1b377f92dd91 Mon Sep 17 00:00:00 2001 From: Tiago Trevisan Jost Date: Tue, 12 Mar 2024 17:36:18 +0100 Subject: [PATCH 2/2] chore: remove TOSA tests that lowered to tosa.custom --- e2e_testing/xfail_sets.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/e2e_testing/xfail_sets.py b/e2e_testing/xfail_sets.py index a624675727b4..584eb09de1bb 100644 --- a/e2e_testing/xfail_sets.py +++ b/e2e_testing/xfail_sets.py @@ -1037,11 +1037,6 @@ "ElementwiseMinOtherModule_basic", "ElementwiseMaximumModule_basic", "ElementwiseMaximumIntModule_basic", - "ElementwiseSinModule_basic", - "ElementwiseCosModule_basic", - "ElementwiseAcosTensorFloatModule_basic", - "ElementwiseAsinTensorFloatModule_basic", - "ElementwiseAtan2TensorFloatModule_basic", "ElementwiseClampMaxModule_basic", "ElementwiseClampMinModule_basic", "ElementwiseClampModule_basic",