From 1111875236ef66cfff77c9ca15f593e6b5479dc7 Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Tue, 10 Jun 2025 10:07:28 -0700 Subject: [PATCH] Back out "Tests failing for exp op in xnnpack" Summary: Diff Train landed PR broke a bunch of internal tests. Reverting Differential Revision: D76350728 --- backends/xnnpack/operators/__init__.py | 1 - backends/xnnpack/operators/op_exp.py | 52 ------------------- backends/xnnpack/partition/config/__init__.py | 4 +- .../partition/config/generic_node_configs.py | 7 --- backends/xnnpack/partition/configs.py | 1 - backends/xnnpack/runtime/XNNCompiler.cpp | 31 ----------- .../xnnpack/serialization/runtime_schema.fbs | 1 - backends/xnnpack/serialization/schema.fbs | 1 - .../serialization/xnnpack_graph_schema.py | 5 -- backends/xnnpack/test/ops/test_exp.py | 45 ---------------- 10 files changed, 1 insertion(+), 147 deletions(-) delete mode 100644 backends/xnnpack/operators/op_exp.py delete mode 100644 backends/xnnpack/test/ops/test_exp.py diff --git a/backends/xnnpack/operators/__init__.py b/backends/xnnpack/operators/__init__.py index 7eafe91eaea..35ce639978d 100644 --- a/backends/xnnpack/operators/__init__.py +++ b/backends/xnnpack/operators/__init__.py @@ -19,7 +19,6 @@ op_dynamic_dequantize_ops, op_dynamic_quantize_ops, op_elu, - op_exp, op_floor, op_gelu, op_hardswish, diff --git a/backends/xnnpack/operators/op_exp.py b/backends/xnnpack/operators/op_exp.py deleted file mode 100644 index e9c6444ad5a..00000000000 --- a/backends/xnnpack/operators/op_exp.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. - -from typing import Dict - -import torch -from executorch.backends.xnnpack.operators.node_visitor import ( - NodeVisitor, - register_node_visitor, -) -from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( - XNNExp, - XNNGraph, - XNode, -) -from executorch.backends.xnnpack.utils.utils import get_input_node - - -@register_node_visitor -class ExpVisitor(NodeVisitor): - target = "aten.exp.default" - - def __init__(self, *args) -> None: - super().__init__(*args) - - def define_node( - self, - node: torch.fx.Node, - xnn_graph: XNNGraph, - vals_to_ids: Dict[torch.fx.Node, int], - debug_handle: int, - ) -> None: - self.define_nodes_tensor_inputs_outputs(node, xnn_graph, vals_to_ids) - - # input - input_id = vals_to_ids[get_input_node(node, 0)] - - # output - output_id = vals_to_ids[node] - - ser_node = XNode( - xnode_union=XNNExp( - input_id=input_id, - output_id=output_id, - flags=0, - ), - debug_handle=debug_handle, - ) - xnn_graph.xnodes.append(ser_node) diff --git a/backends/xnnpack/partition/config/__init__.py b/backends/xnnpack/partition/config/__init__.py index 3c45788cb7d..207d2cfd713 100644 --- a/backends/xnnpack/partition/config/__init__.py +++ b/backends/xnnpack/partition/config/__init__.py @@ -25,11 +25,10 @@ ConstantPadConfig, DeQuantizedPerTensorConfig, DivConfig, - # EluConfig, - # ExpConfig, # Bug in XNNPACK with exp op FloorConfig, GeluConfig, HardswishConfig, + # EluConfig, HardtanhConfig, LeakyReLUConfig, LogConfig, @@ -81,7 +80,6 @@ ClampConfig, DivConfig, # EluConfig, # Waiting for PyTorch Pin Update - # ExpConfig, # Bug in XNNPACK with exp op FloorConfig, GeluConfig, HardtanhConfig, diff --git a/backends/xnnpack/partition/config/generic_node_configs.py b/backends/xnnpack/partition/config/generic_node_configs.py index b1b53256039..e7e298053c6 100644 --- a/backends/xnnpack/partition/config/generic_node_configs.py +++ b/backends/xnnpack/partition/config/generic_node_configs.py @@ -336,13 +336,6 @@ def get_original_aten(self) -> Optional[torch._ops.OpOverload]: return torch.ops.aten.upsample_bilinear2d.vec -class ExpConfig(GenericNodePartitionerConfig): - target_name = "exp.default" - - def supported_precision_types(self) -> List[ConfigPrecisionType]: - return [ConfigPrecisionType.FP32] - - class FloorConfig(GenericNodePartitionerConfig): target_name = "floor.default" diff --git a/backends/xnnpack/partition/configs.py b/backends/xnnpack/partition/configs.py index defdbe172a9..246f571c9c8 100644 --- a/backends/xnnpack/partition/configs.py +++ b/backends/xnnpack/partition/configs.py @@ -59,7 +59,6 @@ exir_ops.edge.aten.sigmoid.default, exir_ops.edge.aten._softmax.default, exir_ops.edge.aten.cat.default, - # exir_ops.edge.aten.exp.default, # Bug in XNNPACK with exp op exir_ops.edge.aten.elu.default, exir_ops.edge.aten.avg_pool2d.default, exir_ops.edge.aten.leaky_relu.default, diff --git a/backends/xnnpack/runtime/XNNCompiler.cpp b/backends/xnnpack/runtime/XNNCompiler.cpp index b4373593649..8ca6a7f26fd 100644 --- a/backends/xnnpack/runtime/XNNCompiler.cpp +++ b/backends/xnnpack/runtime/XNNCompiler.cpp @@ -1761,36 +1761,6 @@ Error defineELUNode( return Error::Ok; } -/* -Define serialized exp node into the subgraph, using the remapped ids -to map the serialized ids, to the new ids generated when defining the -tensor value -*/ -Error defineExpNode( - xnn_subgraph_t subgraph_ptr, - const std::unordered_map& remapped_ids, - const NodePtr node, - const fb_xnnpack::XNNGraph* graph) noexcept { - MAYBE_UNUSED(graph); - - auto graph_node = node->xnode_union_as_XNNExp(); - - xnn_status status = xnn_define_exp( - subgraph_ptr, - remapped_ids.at(graph_node->input_id()), - remapped_ids.at(graph_node->output_id()), - graph_node->flags()); - - ET_CHECK_OR_RETURN_ERROR( - status == xnn_status_success, - Internal, - "Failed to create exp node %i with code: %s", - node->debug_handle(), - xnn_status_to_string(status)); - - return Error::Ok; -} - /* Defines absolute value node into subgraph using the remapped ids to map the serialized ids to the new ids generated when defining the tensor value @@ -2151,7 +2121,6 @@ DefineNodeFunc getDefineNodeFunc(fb_xnnpack::XNodeUnion nodeType) { _DEFINE(Negate) _DEFINE(Square) _DEFINE(ELU) - _DEFINE(Exp) _DEFINE(Abs) _DEFINE(PReLU) _DEFINE(Concatenate2) diff --git a/backends/xnnpack/serialization/runtime_schema.fbs b/backends/xnnpack/serialization/runtime_schema.fbs index 766989cb3e6..eea4cdb8b86 100644 --- a/backends/xnnpack/serialization/runtime_schema.fbs +++ b/backends/xnnpack/serialization/runtime_schema.fbs @@ -141,7 +141,6 @@ union XNodeUnion { XNNNegate: _XNNNode1x1, XNNSquare: _XNNNode1x1, XNNELU, - XNNExp: _XNNNode1x1, XNNAbs: _XNNNode1x1, XNNPReLU: _XNNNode2x1, XNNConcatenate2: _XNNCat, diff --git a/backends/xnnpack/serialization/schema.fbs b/backends/xnnpack/serialization/schema.fbs index 7abce60cd54..ed444005c64 100644 --- a/backends/xnnpack/serialization/schema.fbs +++ b/backends/xnnpack/serialization/schema.fbs @@ -137,7 +137,6 @@ union XNodeUnion { XNNNegate: _XNNNode1x1, XNNSquare: _XNNNode1x1, XNNELU, - XNNExp: _XNNNode1x1, XNNAbs: _XNNNode1x1, XNNPReLU: _XNNNode2x1, XNNConcatenate2: _XNNCat, diff --git a/backends/xnnpack/serialization/xnnpack_graph_schema.py b/backends/xnnpack/serialization/xnnpack_graph_schema.py index 99b64708f86..106eb6b81d9 100644 --- a/backends/xnnpack/serialization/xnnpack_graph_schema.py +++ b/backends/xnnpack/serialization/xnnpack_graph_schema.py @@ -291,11 +291,6 @@ class XNNCeiling(XNNNode1x1): pass -@dataclass -class XNNExp(XNNNode1x1): - pass - - @dataclass class XNNGelu(XNNNode1x1): pass diff --git a/backends/xnnpack/test/ops/test_exp.py b/backends/xnnpack/test/ops/test_exp.py deleted file mode 100644 index 42894bbc217..00000000000 --- a/backends/xnnpack/test/ops/test_exp.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. - -import unittest - -import torch -from executorch.backends.xnnpack.test.tester import Tester - - -class TestExp(unittest.TestCase): - def setUp(self): - torch._dynamo.reset() - - class Exp(torch.nn.Module): - def __init__(self): - super().__init__() - - def forward(self, x): - return torch.exp(x) - - def run_exp_test(self, inputs): - ( - Tester(self.Exp(), inputs) - .export() - .check_count({"torch.ops.aten.exp.default": 1}) - .to_edge_transform_and_lower() - .check_count({"torch.ops.higher_order.executorch_call_delegate": 1}) - .check_not(["executorch_exir_dialects_edge__ops_aten_exp_default"]) - .to_executorch() - .serialize() - .run_method_and_compare_outputs() - ) - - @unittest.skip("D76283309, bug to fix") - def test_fp16_exp(self): - inputs = (torch.randn(20).to(torch.float16),) - self.run_exp_test(inputs) - - @unittest.skip("D76283309, bug to fix") - def test_fp32_exp(self): - inputs = (torch.randn(20),) - self.run_exp_test(inputs)