Skip to content

Commit 8484aee

Browse files
authored
Arm backend: Backend test serializes and uses EthosUQuant on Ethos-U flows (#14817)
### Summary Serialize and quantize automaticaly when possible. This make Ethos-U flows work. ### Test plan This is runned by the backed suit testing for Ethos-U Signed-off-by: Zingo Andersen <[email protected]>
1 parent 563a5d2 commit 8484aee

File tree

1 file changed

+28
-32
lines changed
  • backends/test/suite/flows

1 file changed

+28
-32
lines changed

backends/test/suite/flows/arm.py

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,66 @@
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
55

6+
# Create flows for Arm Backends used to test operator and model suits
67

7-
from executorch.backends.arm.quantizer import (
8-
get_symmetric_quantization_config,
9-
TOSAQuantizer,
10-
)
8+
from executorch.backends.arm.common.arm_compile_spec import ArmCompileSpec
9+
from executorch.backends.arm.quantizer import get_symmetric_quantization_config
1110
from executorch.backends.arm.test import common
1211
from executorch.backends.arm.test.tester.arm_tester import ArmTester
12+
from executorch.backends.arm.tosa.compile_spec import TosaCompileSpec
13+
from executorch.backends.arm.util._factory import create_quantizer
1314
from executorch.backends.test.suite.flow import TestFlow
1415
from executorch.backends.xnnpack.test.tester.tester import Quantize
1516

1617

17-
def _create_tosa_flow(
18+
def _create_arm_flow(
1819
name,
19-
compile_spec,
20-
quantize: bool = False,
20+
compile_spec: ArmCompileSpec,
2121
symmetric_io_quantization: bool = False,
2222
per_channel_quantization: bool = True,
2323
) -> TestFlow:
2424

2525
def _create_arm_tester(*args, **kwargs) -> ArmTester:
2626
kwargs["compile_spec"] = compile_spec
27+
return ArmTester(*args, **kwargs)
28+
29+
support_serialize = not isinstance(compile_spec, TosaCompileSpec)
30+
quantize = compile_spec.tosa_spec.support_integer()
2731

28-
return ArmTester(
29-
*args,
30-
**kwargs,
31-
)
32+
if quantize is True:
3233

33-
# Create and configure quantizer to use in the flow
34-
def create_quantize_stage() -> Quantize:
35-
quantizer = TOSAQuantizer(compile_spec)
36-
quantization_config = get_symmetric_quantization_config(
37-
is_per_channel=per_channel_quantization
38-
)
39-
if symmetric_io_quantization:
40-
quantizer.set_io(quantization_config)
41-
return Quantize(quantizer, quantization_config)
34+
def create_quantize_stage() -> Quantize:
35+
quantizer = create_quantizer(compile_spec)
36+
quantization_config = get_symmetric_quantization_config(
37+
is_per_channel=per_channel_quantization
38+
)
39+
if symmetric_io_quantization:
40+
quantizer.set_io(quantization_config)
41+
return Quantize(quantizer, quantization_config)
4242

4343
return TestFlow(
4444
name,
4545
backend="arm",
4646
tester_factory=_create_arm_tester,
47-
supports_serialize=False,
47+
supports_serialize=support_serialize,
4848
quantize=quantize,
49-
quantize_stage_factory=create_quantize_stage if quantize else None,
49+
quantize_stage_factory=(create_quantize_stage if quantize is True else False),
5050
)
5151

5252

53-
ARM_TOSA_FP_FLOW = _create_tosa_flow(
54-
"arm_tosa_fp", common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+FP")
53+
ARM_TOSA_FP_FLOW = _create_arm_flow(
54+
"arm_tosa_fp",
55+
common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+FP"),
5556
)
56-
ARM_TOSA_INT_FLOW = _create_tosa_flow(
57+
ARM_TOSA_INT_FLOW = _create_arm_flow(
5758
"arm_tosa_int",
5859
common.get_tosa_compile_spec(tosa_spec="TOSA-1.0+INT"),
59-
quantize=True,
6060
)
61-
62-
ARM_ETHOS_U55_FLOW = _create_tosa_flow(
61+
ARM_ETHOS_U55_FLOW = _create_arm_flow(
6362
"arm_ethos_u55",
6463
common.get_u55_compile_spec(),
65-
quantize=True,
6664
)
67-
68-
ARM_ETHOS_U85_FLOW = _create_tosa_flow(
65+
ARM_ETHOS_U85_FLOW = _create_arm_flow(
6966
"arm_ethos_u85",
7067
common.get_u85_compile_spec(),
71-
quantize=True,
7268
)

0 commit comments

Comments
 (0)