Skip to content

Commit ff28b0d

Browse files
committed
Add TosaSpecification to ArmPartitioner
The TOSA specification is added as an argument to TOSASupportedOperators to be able to make decisions on which operators to support. Signed-off-by: Per Åstrand <[email protected]> Change-Id: I5ba3b9dd5f5dca54c3c6d8db29ebc9c52d5cc0f7
1 parent ecdc007 commit ff28b0d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

backends/arm/arm_partitioner.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import torch
1414
from executorch.backends.arm.arm_backend import ArmBackend # usort: skip
1515
from executorch.backends.arm._passes.tag_io_quant_pass import TagIOQuantPass
16+
from executorch.backends.arm.tosa_specification import TosaSpecification
1617
from executorch.exir.backend.compile_spec_schema import CompileSpec
1718
from executorch.exir.backend.partitioner import (
1819
DelegationSpec,
@@ -36,6 +37,10 @@
3637

3738

3839
class TOSASupportedOperators(OperatorSupportBase):
40+
def __init__(self, tosa_spec: TosaSpecification):
41+
super().__init__()
42+
self.tosa_spec = tosa_spec
43+
3944
def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
4045
supported = node.op == "call_function" and node.target in [
4146
exir_ops.edge.aten.add.Tensor,
@@ -111,6 +116,12 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult:
111116
logger.info("ArmPartitioner::partition")
112117
partition_tags = {}
113118

119+
tosa_spec = TosaSpecification.create_from_compilespecs(
120+
self.delegation_spec.compile_specs
121+
)
122+
123+
logger.info(f"Partitioning for {tosa_spec}")
124+
114125
for spec in self.delegation_spec.compile_specs:
115126
if spec.key == "quantize_io" and spec.value.decode() == "True":
116127
# Exclude IO quantization from the partition
@@ -123,7 +134,7 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult:
123134

124135
capability_partitioner = CapabilityBasedPartitioner(
125136
exported_program.graph_module,
126-
TOSASupportedOperators(),
137+
TOSASupportedOperators(tosa_spec),
127138
allows_single_node_partition=True,
128139
)
129140
partition_list = capability_partitioner.propose_partitions()

0 commit comments

Comments
 (0)