1010
1111from executorch .backends .nxp .backend .data_format import DataFormat , NXP_NODE_FORMAT
1212from executorch .backends .nxp .backend .edge_helper import (
13- input_rank ,
1413 is_channels_last_dim_order ,
1514 try_get_arg ,
1615)
2726 MaxPool2DWithIndices ,
2827 MeanDim ,
2928 PermuteCopy ,
30- Prelu ,
3129 QuantizePerTensor ,
3230 SumDimIntList ,
3331 UpsampleBilinear2D ,
@@ -56,11 +54,6 @@ class NodeFormatInference:
5654 UpsampleNearest2D : {"inputs" : [0 ]},
5755 }
5856
59- ops_conditionally_with_channels_first_nodes = {
60- Prelu : {"inputs" : [0 ]},
61- torch .ops .aten .prelu .default : {"inputs" : [0 ]},
62- }
63-
6457 # A set of Edge Aten ops, which have the ability to change the format (for example - input nodes
6558 # are channels first but output is formatless).
6659 ops_that_can_change_tensor_format = {
@@ -71,8 +64,6 @@ class NodeFormatInference:
7164 SumDimIntList ,
7265 }
7366
74- prelu_targets = [Prelu , torch .ops .aten .prelu .default ]
75-
7667 _type_changed_during_last_run : bool
7768
7869 # Mapping between Node and its ancestors (inputs)
@@ -169,13 +160,6 @@ def _infer_format_of_nodes(self, node: Node):
169160 f"Node format inference for node type: { op_type } not found!"
170161 )
171162
172- elif node .target in self .prelu_targets :
173- num_parameters_shape = tuple (node .args [1 ].meta ["val" ].shape )
174- if input_rank (node , 0 ) > 2 and num_parameters_shape != (1 ,):
175- self ._handle_node_which_uses_channels_first_format (node )
176- else :
177- self ._handle_node_which_can_use_any_node_format (node )
178-
179163 elif node .op != "call_function" or (
180164 hasattr (node , "target" ) and node .target in self ._known_targets
181165 ):
@@ -264,14 +248,10 @@ def _handle_node_which_uses_channels_first_format(self, node: Node):
264248 Function for assigning format to nodes that require channels first input (Conv, MaxPool etc.)
265249 """
266250 op_type = self ._get_node_op_type (node )
267- ops_using_channels_first_format = (
268- self .ops_with_channels_first_nodes
269- | self .ops_conditionally_with_channels_first_nodes
270- )
271251
272252 for index , ancestor_node in enumerate (self ._node_inputs [node ]):
273253 # Go through input nodes and assign them correct format
274- if index in ops_using_channels_first_format [op_type ]["inputs" ]:
254+ if index in self . ops_with_channels_first_nodes [op_type ]["inputs" ]:
275255 self ._assign_format_to_node (ancestor_node , DataFormat .CHANNELS_FIRST )
276256
277257 # We need to propagate channels first format up to already visited nodes
0 commit comments