Skip to content

Commit acf5b4b

Browse files
authored
Arm backend: Backend flow should not share compile spec object (#15632)
### Summary Delay compile-spec creation in the backend test flow to prevent sharing the temp directory between tests. Previously, using a shared compile spec implied a shared temp directory. After we began cleaning the temp directory after each test, this sharing caused conflicts. ### Test plan This is tested by the Backend test flow Signed-off-by: Zingo Andersen <Zingo.Andersen@arm.com>
1 parent d9a45a4 commit acf5b4b

File tree

1 file changed

+23
-15
lines changed
  • backends/test/suite/flows

1 file changed

+23
-15
lines changed

backends/test/suite/flows/arm.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,76 @@
55

66
# Create flows for Arm Backends used to test operator and model suits
77

8+
from collections.abc import Callable
9+
810
from executorch.backends.arm.common.arm_compile_spec import ArmCompileSpec
911
from executorch.backends.arm.quantizer import get_symmetric_quantization_config
1012
from executorch.backends.arm.test import common
1113
from executorch.backends.arm.test.tester.arm_tester import ArmTester
12-
from executorch.backends.arm.tosa.compile_spec import TosaCompileSpec
1314
from executorch.backends.arm.util._factory import create_quantizer
1415
from executorch.backends.test.suite.flow import TestFlow
1516
from executorch.backends.xnnpack.test.tester.tester import Quantize
1617

1718

1819
def _create_arm_flow(
19-
name,
20-
compile_spec: ArmCompileSpec,
20+
name: str,
21+
compile_spec_factory: Callable[[], ArmCompileSpec],
22+
support_serialize: bool = True,
23+
quantize: bool = True,
2124
symmetric_io_quantization: bool = False,
2225
per_channel_quantization: bool = True,
2326
use_portable_ops: bool = True,
2427
timeout: int = 1200,
2528
) -> TestFlow:
2629

2730
def _create_arm_tester(*args, **kwargs) -> ArmTester:
28-
kwargs["compile_spec"] = compile_spec
31+
spec = compile_spec_factory()
32+
kwargs["compile_spec"] = spec
2933
return ArmTester(
3034
*args, **kwargs, use_portable_ops=use_portable_ops, timeout=timeout
3135
)
3236

33-
support_serialize = not isinstance(compile_spec, TosaCompileSpec)
34-
quantize = compile_spec.tosa_spec.support_integer()
35-
36-
if quantize is True:
37+
if quantize:
3738

3839
def create_quantize_stage() -> Quantize:
39-
quantizer = create_quantizer(compile_spec)
40+
spec = compile_spec_factory()
41+
quantizer = create_quantizer(spec)
4042
quantization_config = get_symmetric_quantization_config(
4143
is_per_channel=per_channel_quantization
4244
)
4345
if symmetric_io_quantization:
4446
quantizer.set_io(quantization_config)
45-
return Quantize(quantizer, quantization_config)
47+
return Quantize(quantizer, quantization_config) # type: ignore
4648

4749
return TestFlow(
4850
name,
4951
backend="arm",
5052
tester_factory=_create_arm_tester,
5153
supports_serialize=support_serialize,
5254
quantize=quantize,
53-
quantize_stage_factory=(create_quantize_stage if quantize is True else False),
55+
quantize_stage_factory=(create_quantize_stage if quantize else False), # type: ignore
5456
)
5557

5658

5759
ARM_TOSA_FP_FLOW = _create_arm_flow(
5860
"arm_tosa_fp",
59-
common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+FP"),
61+
lambda: common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+FP"),
62+
support_serialize=False,
63+
quantize=False,
6064
)
6165
ARM_TOSA_INT_FLOW = _create_arm_flow(
6266
"arm_tosa_int",
63-
common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+INT"),
67+
lambda: common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+INT"),
68+
support_serialize=False,
69+
quantize=True,
6470
)
6571
ARM_ETHOS_U55_FLOW = _create_arm_flow(
6672
"arm_ethos_u55",
67-
common.get_u55_compile_spec(),
73+
lambda: common.get_u55_compile_spec(),
74+
quantize=True,
6875
)
6976
ARM_ETHOS_U85_FLOW = _create_arm_flow(
7077
"arm_ethos_u85",
71-
common.get_u85_compile_spec(),
78+
lambda: common.get_u85_compile_spec(),
79+
quantize=True,
7280
)

0 commit comments

Comments
 (0)