Skip to content

Commit 00dbb99

Browse files
committed
NXP backend: Replace CustomDelegationOptions with NeutronTargetSpec in new Neutron C flow references
1 parent 04b1d38 commit 00dbb99

20 files changed

Lines changed: 27 additions & 33 deletions

backends/nxp/backend/custom_delegation_options.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@ class CustomDelegationOptions:
2222
# not create any NeutronGraph that can be called. This is done by the partitioner itself, and is not handled by
2323
# the individual node converters.
2424
allow_no_op_partitions: bool = False
25-
26-
# The new neutron converter flow has different constraints for supported operators. These need to be addressed when
27-
# deciding is operator is delegated or not in _is_supported_on_target().
28-
use_new_flow_neutron_c: bool = False

backends/nxp/backend/ir/converter/node_converters/ops_converters/abs_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
import torch
8-
98
from executorch.backends.nxp.backend.ir.converter.node_converter import (
109
CustomDelegationOptions,
1110
NeutronTargetSpec,
@@ -36,7 +35,7 @@ def _is_supported_on_target(
3635
custom_delegation_options: CustomDelegationOptions,
3736
) -> bool:
3837

39-
if custom_delegation_options.use_new_flow_neutron_c:
38+
if neutron_target_spec.use_new_flow_neutron_c:
4039
# Requirements specified by the new Neutron flow documentation.
4140

4241
supported_types = [torch.int8, torch.uint8]

backends/nxp/backend/ir/converter/node_converters/ops_converters/adaptive_avg_pool_2d_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _is_supported_on_target(
7878
AdaptiveAvgPool2dConverter._get_equivalent_avg_pool_parameters(node)
7979
)
8080

81-
if custom_delegation_options.use_new_flow_neutron_c:
81+
if neutron_target_spec.use_new_flow_neutron_c:
8282
# Requirements specified by the new Neutron flow documentation.
8383

8484
if not NodeConverter.uses_quantization_type_for_io(

backends/nxp/backend/ir/converter/node_converters/ops_converters/add_tensor_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _is_supported_on_target(
2626
parameters_mapping: dict[str, Parameter],
2727
custom_delegation_options: CustomDelegationOptions,
2828
) -> bool:
29-
if custom_delegation_options.use_new_flow_neutron_c:
29+
if neutron_target_spec.use_new_flow_neutron_c:
3030
if not NodeConverter.at_least_one_input_shape_matches_the_output_shape(
3131
node
3232
):

backends/nxp/backend/ir/converter/node_converters/ops_converters/avg_pool_2d_converter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77
import torch
8-
98
from executorch.backends.nxp.backend.ir.converter.conversion import (
109
aten_translator,
1110
common,
@@ -22,7 +21,6 @@
2221
from executorch.backends.nxp.backend.ir.tflite_generator.builtin_options import (
2322
average_pool_2d_options,
2423
)
25-
2624
from executorch.backends.nxp.backend.neutron_target_spec import NeutronTargetSpec
2725
from torch.fx import Node
2826
from torch.nn import Parameter
@@ -66,7 +64,7 @@ def _is_supported_on_target(
6664
kernel = node.args[1]
6765
stride = node.args[2]
6866

69-
if custom_delegation_options.use_new_flow_neutron_c:
67+
if neutron_target_spec.use_new_flow_neutron_c:
7068
# Requirements specified by the new Neutron flow documentation.
7169

7270
supported_types = [torch.int8, torch.uint8]

backends/nxp/backend/ir/converter/node_converters/ops_converters/constant_pad_nd_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _is_supported_on_target(
4242
parameters_mapping: dict[str, Parameter],
4343
custom_delegation_options: CustomDelegationOptions,
4444
) -> bool:
45-
if custom_delegation_options.use_new_flow_neutron_c:
45+
if neutron_target_spec.use_new_flow_neutron_c:
4646
# Requirements specified by the new Neutron flow documentation.
4747

4848
if not NodeConverter.uses_quantization_type_for_io(

backends/nxp/backend/ir/converter/node_converters/ops_converters/leaky_relu_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _is_supported_on_target(
3535
parameters_mapping: dict[str, Parameter],
3636
custom_delegation_options: CustomDelegationOptions,
3737
) -> bool:
38-
if custom_delegation_options.use_new_flow_neutron_c:
38+
if neutron_target_spec.use_new_flow_neutron_c:
3939
# Requirements specified by the new Neutron flow documentation.
4040

4141
if not NodeConverter.uses_quantization_type_for_io(

backends/nxp/backend/ir/converter/node_converters/ops_converters/max_pool2d_with_indices_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import numpy as np
99
import torch
10-
1110
from executorch.backends.nxp.backend.edge_helper import try_get_arg
1211
from executorch.backends.nxp.backend.ir.converter.conversion import (
1312
aten_translator,
@@ -74,7 +73,7 @@ def _is_supported_on_target(
7473
MaxPool2DWithIndicesConverter._get_node_args(node)
7574
)
7675

77-
if custom_delegation_options.use_new_flow_neutron_c:
76+
if neutron_target_spec.use_new_flow_neutron_c:
7877
# Requirements specified by the new Neutron flow documentation.
7978

8079
supported_types = [torch.int8, torch.uint8]

backends/nxp/backend/ir/converter/node_converters/ops_converters/mean_dim_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def supports_partitioning_result(
3838
neutron_target_spec: NeutronTargetSpec,
3939
parameters_mapping: dict[str, Parameter],
4040
) -> bool:
41-
if custom_delegation_options.use_new_flow_neutron_c:
41+
if neutron_target_spec.use_new_flow_neutron_c:
4242
dim, keepdim = MeanDimConverter._get_attrs(node)
4343
input_shape = node.args[0].meta["val"].shape
4444

@@ -64,7 +64,7 @@ def _is_supported_on_target(
6464
parameters_mapping: dict[str, Parameter],
6565
custom_delegation_options: CustomDelegationOptions,
6666
) -> bool:
67-
if custom_delegation_options.use_new_flow_neutron_c:
67+
if neutron_target_spec.use_new_flow_neutron_c:
6868
# Requirements specified by the new Neutron flow documentation.
6969

7070
if not NodeConverter.uses_quantization_type_for_io(

backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# LICENSE file in the root directory of this source tree.
55

66
import torch
7-
87
from executorch.backends.nxp.backend.data_format import NXP_NODE_FORMAT
98
from executorch.backends.nxp.backend.ir.converter.node_converter import (
109
CustomDelegationOptions,
@@ -26,7 +25,7 @@ def _is_supported_on_target(
2625
parameters_mapping: dict[str, Parameter],
2726
custom_delegation_options: CustomDelegationOptions,
2827
) -> bool:
29-
if custom_delegation_options.use_new_flow_neutron_c:
28+
if neutron_target_spec.use_new_flow_neutron_c:
3029
if not NodeConverter.at_least_one_input_shape_matches_the_output_shape(
3130
node
3231
):

0 commit comments

Comments
 (0)