From 1dbc56b71c3571243ef85d09a6302121a77350cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Thu, 17 Oct 2024 15:26:28 +0200 Subject: [PATCH 1/5] Add a TOSA specification class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Per Åstrand Change-Id: I45374812daaa831f8084f6534b4903d14d6634b8 --- backends/arm/test/misc/test_tosa_spec.py | 105 +++++++++++ backends/arm/tosa_specification.py | 226 +++++++++++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 backends/arm/test/misc/test_tosa_spec.py create mode 100644 backends/arm/tosa_specification.py diff --git a/backends/arm/test/misc/test_tosa_spec.py b/backends/arm/test/misc/test_tosa_spec.py new file mode 100644 index 00000000000..5cbad140b77 --- /dev/null +++ b/backends/arm/test/misc/test_tosa_spec.py @@ -0,0 +1,105 @@ +# Copyright 2024 Arm Limited and/or its affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +import unittest + +from executorch.backends.arm.tosa_specification import ( + Tosa_0_80, + Tosa_1_00, + TosaSpecification, +) + +from executorch.exir.backend.compile_spec_schema import CompileSpec +from parameterized import parameterized + +test_valid_0_80_strings = [ + "TOSA-0.80.0+BI", + "TOSA-0.80.0+MI+8k", + "TOSA-0.80.0+BI+u55", +] +test_valid_1_00_strings = [ + "TOSA-1.00.0+INT+FP+fft", + "TOSA-1.00.0+FP+bf16+fft", + "TOSA-1.00.0+INT+int4+cf", + "TOSA-1.00.0+FP+cf+bf16+8k", + "TOSA-1.00.0+FP+INT+bf16+fft+int4+cf", + "TOSA-1.00.0+FP+INT+fft+int4+cf+8k", +] + +test_valid_1_00_extensions = { + "INT": ["int16", "int4", "var", "cf"], + "FP": ["bf16", "fp8e4m3", "fp8e5m2", "fft", "var", "cf"], +} + +test_invalid_strings = [ + "TOSA-0.80.0+bi", + "TOSA-0.80.0", + "TOSA-0.80.0+8k", + "TOSA-0.80.0+BI+MI", + "TOSA-0.80.0+BI+U55", + "TOSA-1.00.0+fft", + "TOSA-1.00.0+fp+bf16+fft", + "TOSA-1.00.0+INT+INT4+cf", + "TOSA-1.00.0+BI", + "TOSA-1.00.0+FP+FP+INT", + "TOSA-1.00.0+FP+CF+bf16", + "TOSA-1.00.0+BF16+fft+int4+cf+INT", +] + +test_compile_specs = [ + ([CompileSpec("tosa_version", "TOSA-0.80.0+BI".encode())],), + ([CompileSpec("tosa_version", "TOSA-0.80.0+BI+u55".encode())],), + ([CompileSpec("tosa_version", "TOSA-1.00.0+INT".encode())],), +] + +test_compile_specs_no_version = [ + ([CompileSpec("other_key", "TOSA-0.80.0+BI".encode())],), + ([CompileSpec("other_key", "some_value".encode())],), +] + + +class TestTosaSpecification(unittest.TestCase): + """Tests the TOSA specification class""" + + @parameterized.expand(test_valid_0_80_strings) + def test_version_string_0_80(self, version_string: str): + tosa_spec = TosaSpecification.create_from_string(version_string) + assert isinstance(tosa_spec, Tosa_0_80) + assert tosa_spec.profile in ["BI", "MI"] + + @parameterized.expand(test_valid_1_00_strings) + def test_version_string_1_00(self, version_string: str): + tosa_spec = TosaSpecification.create_from_string(version_string) + assert isinstance(tosa_spec, Tosa_1_00) + assert [profile in ["INT", "FP"] for profile in tosa_spec.profiles].count( + True + ) > 0 + + for profile in tosa_spec.profiles: + assert [ + e in test_valid_1_00_extensions[profile] for e in tosa_spec.extensions + ] + + @parameterized.expand(test_invalid_strings) + def test_invalid_version_strings(self, version_string: str): + tosa_spec = None + with self.assertRaises(ValueError): + tosa_spec = TosaSpecification.create_from_string(version_string) + + assert tosa_spec is None + + @parameterized.expand(test_compile_specs) + def test_create_from_compilespec(self, compile_specs: list[CompileSpec]): + tosa_spec = TosaSpecification.create_from_compilespecs(compile_specs) + assert isinstance(tosa_spec, TosaSpecification) + + @parameterized.expand(test_compile_specs_no_version) + def test_create_from_invalid_compilespec(self, compile_specs: list[CompileSpec]): + tosa_spec = None + with self.assertRaises(ValueError): + tosa_spec = TosaSpecification.create_from_compilespecs(compile_specs) + + assert tosa_spec is None diff --git a/backends/arm/tosa_specification.py b/backends/arm/tosa_specification.py new file mode 100644 index 00000000000..716e8daee23 --- /dev/null +++ b/backends/arm/tosa_specification.py @@ -0,0 +1,226 @@ +# Copyright 2024 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# pyre-unsafe + +# +# Main implementation of AoT flow to partition and preprocess for Arm target +# backends. Converts via TOSA as an intermediate form supported by AoT and +# JIT compiler flows. +# + +import re +from typing import List + +from executorch.exir.backend.compile_spec_schema import CompileSpec +from packaging.version import Version + + +class TosaSpecification: + """ + This class implements a representation of TOSA specification + (https://www.mlplatform.org/tosa/tosa_spec.html) with a version, a profile + (with extension) and a level (8k). + For 0.80 releases the profile is BI or MI, with u55 handled as an inofficial extension + For 1.00 releases the profile is INT or FP, and the extensions are for + INT: int16, int4, var, cf + FP: bf16, fp8e4m3, fp8e5m2, fft, var, cf + + The TOSA specification is encoded in the string represenatation + TOSA-major.minor.patch+profile[+level][+extensions] + + For 0.80 MI implies BI, while for 1.0 the profiles has to explicitely be specified. + + Profiles are uppercase letters and extensions and level is lowercase. + """ + + version: Version + + def support_integer(self) -> bool: + """ + Returns true if any integer operations are supported for the specification. + """ + raise NotImplementedError + + def support_float(self) -> bool: + """ + Returns true if any float operations are supported for the specification. + """ + raise NotImplementedError + + def __init__(self, version: Version): + self.version = version + + @staticmethod + def create_from_compilespecs( + compile_specs: List[CompileSpec], + ) -> "TosaSpecification": + """ + Search the CompileSpec list for 'tosa_version' and instantiate a + class from the found value or return None on failure. + """ + for spec in compile_specs: + if spec.key == "tosa_version": + return TosaSpecification.create_from_string(spec.value.decode()) + raise ValueError( + "No TOSA version key found in any of the supplied CompileSpecs" + ) + + @staticmethod + def create_from_string(repr: str) -> "TosaSpecification": + """ + Creates a TOSA specification class from a string representation: + TOSA-0.80.0+MI + TOSA-0.80.0+BI+8k + TOSA-0.80.0+BI+u55 # Ethos-U55 extension to handle TOSA subset + TOSA-0.90.0+MI + TOSA-1.00.0+INT+FP+int4+cf + """ + + pattern = r"^(TOSA)-([\d.]+)\+(.+)$" + match = re.match(pattern, repr) + if match: + name = match.group(1) + version = Version(match.group(2)) + extras = match.group(3).split("+") + if name != "TOSA": + raise ValueError(f"Malformed TOSA specification representation: {repr}") + match version: + case _ if version.major == 0 and version.minor == 80: + return Tosa_0_80(version, extras) + case _ if version.major == 1 and version.minor == 0: + return Tosa_1_00(version, extras) + case _: + raise ValueError(f"Wrong TOSA version: {version} from {repr}") + + raise ValueError(f"Failed to parse TOSA specification representation: {repr}") + + +class Tosa_0_80(TosaSpecification): + profile: str + level_8k: bool + is_U55_subset: bool + available_profiles = ["BI", "MI"] # MT is not defined + + def __init__(self, version: Version, extras: List[str]): + super().__init__(version) + assert version >= Version("0.80") and version < Version("0.90") + + # Check that we only have one profile in the extensions list + if [e in Tosa_0_80.available_profiles for e in extras].count(True) != 1: + raise ValueError( + f"Bad combination of extras: {extras}, more than one of {Tosa_0_80.available_profiles} found." + ) + + # The list contains one profile at most, so pick it + self.profile = [e for e in extras if e in Tosa_0_80.available_profiles][0] + extras.remove(self.profile) + + self.level_8k = "8k" in extras + if self.level_8k: + extras.remove("8k") + self.is_U55_subset = "u55" in extras + if self.is_U55_subset: + extras.remove("u55") + + if len(extras) > 0: + raise ValueError(f"Unhandled extras found: {extras}") + + def __repr__(self): + extensions = "" + if self.level_8k: + extensions += "+8K" + if self.is_U55_subset: + extensions += "+u55" + return f"TOSA-{str(self.version)}+{self.profile}{extensions}" + + def __hash__(self) -> int: + return hash(str(self.version) + self.profile) + + def __eq__(self, other: object) -> bool: + if isinstance(other, Tosa_0_80): + return (self.version == other.version) and (self.profile == other.profile) + return False + + def support_integer(self): + return True + + def support_float(self): + return self.profile == "MI" + + +class Tosa_1_00(TosaSpecification): + profiles: List[str] + level_8k: bool + extensions: List[str] + + available_profiles = ["INT", "FP"] + valid_extensions = { + "INT": ["int16", "int4", "var", "cf"], + "FP": ["bf16", "fp8e4m3", "fp8e5m2", "fft", "var", "cf"], + } + + def __init__(self, version: Version, extras: List[str]): + super().__init__(version) + + # Check that we have at least one profile in the extensions list + if [e in Tosa_1_00.available_profiles for e in extras].count(True) == 0: + raise ValueError( + f"No profile ({Tosa_1_00.available_profiles}) found in: {extras}." + ) + + # and not more than number of available profiles + if [e in Tosa_1_00.available_profiles for e in extras].count(True) > len( + Tosa_1_00.available_profiles + ): + raise ValueError( + f"Too many profiles ({Tosa_1_00.available_profiles}) found in: {extras}." + ) + + # The list contains one profile at least, so pick them + self.profiles = [e for e in extras if e in Tosa_1_00.available_profiles] + for p in self.profiles: + extras.remove(p) + + self.level_8k = "8k" in extras + if self.level_8k: + extras.remove("8k") + + combined_extensions = [] + for p in self.profiles: + combined_extensions += Tosa_1_00.valid_extensions[p] + + if not all(e in combined_extensions for e in extras): + raise ValueError( + f"Bad extensions for TOSA-{version}{self._get_profiles_string()}: {extras}" + ) + + # all the rest of the extras are handled extensions + self.extensions = extras + + def _get_profiles_string(self) -> str: + return "".join(["+" + p for p in self.profiles]) + + def _get_extensions_string(self) -> str: + return "".join(["+" + e for e in self.extensions]) + + def __repr__(self): + return f"TOSA-{self.version}{self._get_profiles_string()}{self._get_profiles_string()}" + + def __hash__(self) -> int: + return hash(str(self.version) + self._get_profiles_string()) + + def __eq__(self, other: object) -> bool: + if isinstance(other, Tosa_1_00): + return (self.version == other.version) and ( + self._get_profiles_string() == other._get_profiles_string() + ) + return False + + def support_integer(self): + return "INT" in self.profiles + + def support_float(self): + return "FP" in self.profiles From 56dc56a925c219a0d4574df508d4676b84222dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Thu, 17 Oct 2024 15:59:23 +0200 Subject: [PATCH 2/5] Add TOSA specification handling to Arm backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mandate the need for a TOSA version in the compile spec list passed to the Arm backend and propagate the information to node visitors for serialization handling. Signed-off-by: Per Åstrand Change-Id: I43b35923f71a312e3064eab9388a4bd2756dc17f --- backends/arm/arm_backend.py | 31 +++++++++++++++++--- backends/arm/operators/node_visitor.py | 36 ++++++++++++++++++++---- backends/arm/operators/op_placeholder.py | 12 ++++++-- backends/arm/test/common.py | 10 ++++--- backends/arm/tosa_utils.py | 4 ++- examples/arm/aot_arm_compiler.py | 4 ++- 6 files changed, 80 insertions(+), 17 deletions(-) diff --git a/backends/arm/arm_backend.py b/backends/arm/arm_backend.py index 28af583106f..b55f237543b 100644 --- a/backends/arm/arm_backend.py +++ b/backends/arm/arm_backend.py @@ -20,6 +20,8 @@ from executorch.backends.arm.operators.node_visitor import get_node_visitors from executorch.backends.arm.operators.op_output import process_output from executorch.backends.arm.operators.op_placeholder import process_placeholder + +from executorch.backends.arm.tosa_specification import TosaSpecification from executorch.backends.arm._passes.arm_pass_manager import ( ArmPassManager, ) # usort: skip @@ -86,9 +88,15 @@ def ethosu_compile_spec( if extra_flags is not None: self.compiler_flags.append(extra_flags) + base_tosa_version = "TOSA-0.80.0+BI" + if "U55" in config: + # Add the Ethos-U55 extension marker + base_tosa_version += "+u55" + self.tosa_version = TosaSpecification.create_from_string(base_tosa_version) + return self - def tosa_compile_spec(self) -> "ArmCompileSpecBuilder": + def tosa_compile_spec(self, tosa_version: str) -> "ArmCompileSpecBuilder": """ Generate compile spec for TOSA flatbuffer output """ @@ -96,6 +104,7 @@ def tosa_compile_spec(self) -> "ArmCompileSpecBuilder": self.output_format is None ), f"Output format already set: {self.output_format}" self.output_format = "tosa" + self.tosa_version = TosaSpecification.create_from_string(tosa_version) return self def dump_intermediate_artifacts_to( @@ -129,6 +138,13 @@ def build(self) -> List[CompileSpec]: """ Generate a list of compile spec objects from the builder """ + assert self.tosa_version + + # Always supply a TOSA version + self.compile_spec = [ + CompileSpec("tosa_version", str(self.tosa_version).encode()) + ] + if self.output_format == "vela": self.compile_spec += [ CompileSpec("output_format", "vela".encode()), @@ -210,11 +226,18 @@ def preprocess( # noqa: C901 if not output_format: raise RuntimeError("output format is required") + tosa_spec = TosaSpecification.create_from_compilespecs(compile_spec) + assert ( + tosa_spec is not None + ), "TOSA backend needs a TOSA version specified in the CompileSpec!" + if output_format == "vela" and len(compile_flags) == 0: # Not testing for compile_flags correctness here, just that they are # present. The compiler will give errors if they are not valid. raise RuntimeError("compile flags are required for vela output format") + logger.info(f"Converting ExportedProgram to TOSA: {tosa_spec}") + # Converted output for this subgraph, serializer needs path early as it emits # const data directly. Path created and data written only in debug builds. tosa_graph = ts.TosaSerializer(artifact_path) @@ -222,13 +245,13 @@ def preprocess( # noqa: C901 exported_program=edge_program, compile_spec=compile_spec ) - node_visitors = get_node_visitors(edge_program) + node_visitors = get_node_visitors(edge_program, tosa_spec) for node in graph_module.graph.nodes: if node.op == "call_function": - process_call_function(node, tosa_graph, node_visitors) + process_call_function(node, tosa_graph, node_visitors, tosa_spec) elif node.op == "placeholder": - process_placeholder(node, tosa_graph, edge_program) + process_placeholder(node, tosa_graph, edge_program, tosa_spec) elif node.op == "output": process_output(node, tosa_graph) else: diff --git a/backends/arm/operators/node_visitor.py b/backends/arm/operators/node_visitor.py index 99fd0388e45..9e98ebcab98 100644 --- a/backends/arm/operators/node_visitor.py +++ b/backends/arm/operators/node_visitor.py @@ -1,4 +1,4 @@ -# Copyright 2023 Arm Limited and/or its affiliates. +# Copyright 2023-2024 Arm Limited and/or its affiliates. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. @@ -10,6 +10,7 @@ import serializer.tosa_serializer as ts import torch from executorch.backends.arm.tosa_mapping import TosaArg +from executorch.backends.arm.tosa_specification import TosaSpecification from torch.export import ExportedProgram @@ -18,8 +19,19 @@ class NodeVisitor: Node Visitor pattern for lowering edge IR to TOSA """ - def __init__(self, exported_program: ExportedProgram): + # Add the currently supported node_visitor specs as default. + # This should be overriden in the NodeVisitor subclasses to target + # a specific TOSA version. + # When all node_visitors has been refactored to target a specific + # version, this list should be removed. + tosa_specs = [ + TosaSpecification.create_from_string("TOSA-0.80.0+BI"), + TosaSpecification.create_from_string("TOSA-0.80.0+MI"), + ] + + def __init__(self, exported_program: ExportedProgram, tosa_spec: TosaSpecification): self._exported_program = exported_program or None + self.tosa_spec = tosa_spec def define_node( self, @@ -33,16 +45,30 @@ def define_node( # container for all node visitors -_node_visitor_dict = {} +_node_visitor_dicts = { + TosaSpecification.create_from_string("TOSA-0.80.0+BI"): {}, + TosaSpecification.create_from_string("TOSA-0.80.0+MI"): {}, +} def register_node_visitor(visitor): - _node_visitor_dict[visitor.target] = visitor + for tosa_spec in visitor.tosa_specs: + _node_visitor_dicts[tosa_spec][visitor.target] = visitor + return visitor def get_node_visitors(*args) -> Dict[str, NodeVisitor]: node_visitors = {} - for target, visitor in _node_visitor_dict.items(): + tosa_spec = None + for arg in args: + if isinstance(arg, TosaSpecification): + tosa_spec = arg + break + + if tosa_spec is None: + raise RuntimeError("No TOSA specification supplied.") + + for target, visitor in _node_visitor_dicts[tosa_spec].items(): node_visitors[target] = visitor(*args) return node_visitors diff --git a/backends/arm/operators/op_placeholder.py b/backends/arm/operators/op_placeholder.py index 2618c9e71d3..f3e52e68f75 100644 --- a/backends/arm/operators/op_placeholder.py +++ b/backends/arm/operators/op_placeholder.py @@ -14,6 +14,7 @@ get_quant_node_args, is_quant_arg, ) +from executorch.backends.arm.tosa_specification import TosaSpecification from executorch.backends.arm.tosa_utils import ( is_bias_node_for_quantized_addmm, is_bias_node_for_quantized_conv, @@ -26,6 +27,7 @@ def process_inputs( node: torch.fx.Node, tosa_graph: ts.TosaSerializer, + tosa_spec: TosaSpecification, ): """Serialize an input node""" # inputs need to be in default dim_order (contiguous memory format) @@ -95,6 +97,7 @@ def process_inputs_to_parameters( node: torch.fx.Node, tosa_graph: ts.TosaSerializer, edge_program: ExportedProgram, + tosa_spec: TosaSpecification, ): """Serialize bias and non-quantized weights""" inputs = [TosaArg(node)] @@ -106,9 +109,13 @@ def process_inputs_to_parameters( if is_bias_node_for_quantized_addmm(node) or is_bias_node_for_quantized_conv(node): # BI bias + assert tosa_spec.support_integer(), f"{tosa_spec} doesnt't support integer" process_quantized_bias(node, tosa_graph, parameter_values) else: # MI weights or bias + if inputs[0].dtype == torch.float32: + assert tosa_spec.support_float(), f"{tosa_spec} doesn't support float" + parameter_values = np.transpose(parameter_values, inputs[0].dim_order) tosa_graph.addConst( @@ -158,15 +165,16 @@ def process_placeholder( node: torch.fx.Node, tosa_graph: ts.TosaSerializer, edge_program: ExportedProgram, + tosa_spec: TosaSpecification, ): """Wrapper for processing and serializing all types of placeholders""" assert node.name == node.target, "Expect placeholder name and target to match" assert 0 == len(node.args), "Can't handle default input values" if node.name in edge_program.graph_signature.user_inputs: - process_inputs(node, tosa_graph) + process_inputs(node, tosa_graph, tosa_spec) elif node.name in edge_program.graph_signature.inputs_to_parameters: - process_inputs_to_parameters(node, tosa_graph, edge_program) + process_inputs_to_parameters(node, tosa_graph, edge_program, tosa_spec) elif node.name in edge_program.graph_signature.inputs_to_buffers: process_inputs_to_buffers(node, tosa_graph, edge_program) elif node.name in edge_program.graph_signature.inputs_to_lifted_tensor_constants: diff --git a/backends/arm/test/common.py b/backends/arm/test/common.py index b0e2a7f0bb7..3a9818929b9 100644 --- a/backends/arm/test/common.py +++ b/backends/arm/test/common.py @@ -177,16 +177,18 @@ def maybe_get_tosa_collate_path() -> str | None: def get_tosa_compile_spec( - permute_memory_to_nhwc=True, custom_path=None + tosa_version: str, permute_memory_to_nhwc=True, custom_path=None ) -> list[CompileSpec]: """ Default compile spec for TOSA tests. """ - return get_tosa_compile_spec_unbuilt(permute_memory_to_nhwc, custom_path).build() + return get_tosa_compile_spec_unbuilt( + tosa_version, permute_memory_to_nhwc, custom_path + ).build() def get_tosa_compile_spec_unbuilt( - permute_memory_to_nhwc=False, custom_path=None + tosa_version: str, permute_memory_to_nhwc=False, custom_path=None ) -> ArmCompileSpecBuilder: """Get the ArmCompileSpecBuilder for the default TOSA tests, to modify the compile spec before calling .build() to finalize it. @@ -202,7 +204,7 @@ def get_tosa_compile_spec_unbuilt( os.makedirs(intermediate_path, exist_ok=True) compile_spec_builder = ( ArmCompileSpecBuilder() - .tosa_compile_spec() + .tosa_compile_spec(tosa_version) .set_permute_memory_format(permute_memory_to_nhwc) .dump_intermediate_artifacts_to(intermediate_path) ) diff --git a/backends/arm/tosa_utils.py b/backends/arm/tosa_utils.py index cfafac16760..bf60aaf0f89 100644 --- a/backends/arm/tosa_utils.py +++ b/backends/arm/tosa_utils.py @@ -21,6 +21,7 @@ is_quant_node, q_op, ) +from executorch.backends.arm.tosa_specification import TosaSpecification from executorch.exir.dialects._ops import ops as exir_ops from serializer.tosa_serializer import TosaOp from torch.fx import Node @@ -290,6 +291,7 @@ def process_call_function( node: torch.fx.Node, tosa_graph: ts.TosaSerializer, node_visitors: Dict[str, NodeVisitor], + tosa_spec: TosaSpecification, ): # Unpack arguments and convert inputs = getNodeArgs(node) @@ -319,7 +321,7 @@ def process_call_function( is_quant_node(node), ) else: - raise RuntimeError(f"Unknown operator {node.target}") + raise RuntimeError(f"Unknown operator {node.target} for TOSA : {tosa_spec}") def expand_dims( diff --git a/examples/arm/aot_arm_compiler.py b/examples/arm/aot_arm_compiler.py index 3075d992d51..e718c52fdce 100644 --- a/examples/arm/aot_arm_compiler.py +++ b/examples/arm/aot_arm_compiler.py @@ -180,7 +180,9 @@ def get_compile_spec( spec_builder = None if target == "TOSA": spec_builder = ( - ArmCompileSpecBuilder().tosa_compile_spec().set_permute_memory_format(True) + ArmCompileSpecBuilder() + .tosa_compile_spec("TOSA-0.80.0+BI") + .set_permute_memory_format(True) ) elif "ethos-u55" in target: spec_builder = ( From 27ad50e29f0f82db6ead68d22a96961e7ce52bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Thu, 17 Oct 2024 15:16:56 +0200 Subject: [PATCH 3/5] Add TOSA version string to all TOSA tests Change-Id: Ia2b21c14f56793d6a9125ae7371779df93ecf9d5 --- backends/arm/test/misc/test_debug_feats.py | 16 +++++++++------- backends/arm/test/misc/test_dim_order_guards.py | 4 ++-- backends/arm/test/misc/test_lifted_tensor.py | 8 ++++---- .../arm/test/models/test_mobilenet_v2_arm.py | 8 ++++++-- backends/arm/test/ops/test_add.py | 4 ++-- backends/arm/test/ops/test_avg_pool.py | 8 ++++++-- backends/arm/test/ops/test_batch_norm.py | 6 +++--- backends/arm/test/ops/test_bmm.py | 4 ++-- backends/arm/test/ops/test_cat.py | 4 ++-- backends/arm/test/ops/test_clone.py | 4 ++-- backends/arm/test/ops/test_conv1d.py | 8 ++++++-- backends/arm/test/ops/test_conv2d.py | 8 ++++++-- backends/arm/test/ops/test_conv_combos.py | 8 ++++++-- backends/arm/test/ops/test_depthwise_conv.py | 8 ++++++-- backends/arm/test/ops/test_div.py | 4 ++-- backends/arm/test/ops/test_exp.py | 4 ++-- backends/arm/test/ops/test_expand.py | 4 ++-- backends/arm/test/ops/test_full.py | 4 ++-- backends/arm/test/ops/test_hardtanh.py | 4 ++-- backends/arm/test/ops/test_layer_norm.py | 8 ++++++-- backends/arm/test/ops/test_linear.py | 8 ++++++-- backends/arm/test/ops/test_log.py | 4 ++-- backends/arm/test/ops/test_logsoftmax.py | 4 ++-- backends/arm/test/ops/test_mean_dim.py | 8 ++++---- backends/arm/test/ops/test_mm.py | 4 ++-- backends/arm/test/ops/test_mul.py | 8 ++++++-- backends/arm/test/ops/test_permute.py | 4 ++-- backends/arm/test/ops/test_reciprocal.py | 4 ++-- backends/arm/test/ops/test_relu.py | 4 ++-- backends/arm/test/ops/test_repeat.py | 4 ++-- backends/arm/test/ops/test_rsqrt.py | 4 ++-- backends/arm/test/ops/test_scalars.py | 4 ++-- backends/arm/test/ops/test_select.py | 4 ++-- backends/arm/test/ops/test_sigmoid.py | 4 ++-- backends/arm/test/ops/test_slice.py | 4 ++-- backends/arm/test/ops/test_softmax.py | 4 ++-- backends/arm/test/ops/test_split.py | 4 ++-- backends/arm/test/ops/test_squeeze.py | 4 ++-- backends/arm/test/ops/test_sub.py | 4 ++-- backends/arm/test/ops/test_sum.py | 4 ++-- backends/arm/test/ops/test_tanh.py | 4 ++-- backends/arm/test/ops/test_unsqueeze.py | 4 ++-- backends/arm/test/ops/test_var.py | 4 ++-- backends/arm/test/ops/test_view.py | 4 ++-- .../test/passes/test_meandim_to_averagepool2d.py | 4 ++-- .../arm/test/quantizer/test_generic_annotater.py | 4 +++- 46 files changed, 141 insertions(+), 101 deletions(-) diff --git a/backends/arm/test/misc/test_debug_feats.py b/backends/arm/test/misc/test_debug_feats.py index 7d9a18a80e5..66e3e52d4d7 100644 --- a/backends/arm/test/misc/test_debug_feats.py +++ b/backends/arm/test/misc/test_debug_feats.py @@ -49,7 +49,7 @@ def _tosa_MI_pipeline(self, module: torch.nn.Module, dump_file=None): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -63,7 +63,7 @@ def _tosa_BI_pipeline(self, module: torch.nn.Module, dump_file=None): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() @@ -107,7 +107,9 @@ def test_numerical_diff_prints(self): ArmTester( model, example_inputs=model.get_inputs(), - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=False), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=False + ), ) .export() .to_edge() @@ -132,7 +134,7 @@ def test_dump_ops_and_dtypes(): ArmTester( model, example_inputs=model.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .dump_dtype_distribution() @@ -156,7 +158,7 @@ def test_dump_ops_and_dtypes_parseable(): ArmTester( model, example_inputs=model.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .dump_dtype_distribution(print_table=False) @@ -187,7 +189,7 @@ def test_collate_tosa_BI_tests(self): ArmTester( model, example_inputs=model.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() @@ -217,7 +219,7 @@ def test_dump_tosa_ops(caplog): ArmTester( model, example_inputs=model.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/misc/test_dim_order_guards.py b/backends/arm/test/misc/test_dim_order_guards.py index 8bad1493b1c..d7406afe95e 100644 --- a/backends/arm/test/misc/test_dim_order_guards.py +++ b/backends/arm/test/misc/test_dim_order_guards.py @@ -34,7 +34,7 @@ def test_tosa_MI_pipeline(self): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -48,7 +48,7 @@ def test_tosa_BI_pipeline(self): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/misc/test_lifted_tensor.py b/backends/arm/test/misc/test_lifted_tensor.py index 29b2887431c..12b8d0665be 100644 --- a/backends/arm/test/misc/test_lifted_tensor.py +++ b/backends/arm/test/misc/test_lifted_tensor.py @@ -60,7 +60,7 @@ def test_partition_lifted_tensor_tosa_MI(self, op, data): ArmTester( LiftedTensor(op), example_inputs=data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -77,7 +77,7 @@ def test_partition_lifted_tensor_tosa_BI(self, op, data): ArmTester( LiftedTensor(op), example_inputs=data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() @@ -95,7 +95,7 @@ def test_partition_lifted_scalar_tensor_tosa_MI(self, op, data, arg1): ArmTester( LiftedScalarTensor(op, arg1), example_inputs=(data), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -110,7 +110,7 @@ def test_partition_lifted_scalar_tensor_tosa_BI(self, op, data, arg1): ArmTester( LiftedScalarTensor(op, arg1), example_inputs=(data), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/models/test_mobilenet_v2_arm.py b/backends/arm/test/models/test_mobilenet_v2_arm.py index a50e2732f15..97a802b15d6 100644 --- a/backends/arm/test/models/test_mobilenet_v2_arm.py +++ b/backends/arm/test/models/test_mobilenet_v2_arm.py @@ -54,7 +54,9 @@ def test_mv2_tosa_MI(self): ArmTester( self.mv2, example_inputs=self.model_inputs, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .to_edge(config=self._edge_compile_config) @@ -69,7 +71,9 @@ def test_mv2_tosa_BI(self): ArmTester( self.mv2, example_inputs=self.model_inputs, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_add.py b/backends/arm/test/ops/test_add.py index e3eeb187da3..66e278ee0f1 100644 --- a/backends/arm/test/ops/test_add.py +++ b/backends/arm/test/ops/test_add.py @@ -61,7 +61,7 @@ def _test_add_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.add.Tensor": 1}) @@ -80,7 +80,7 @@ def _test_add_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_avg_pool.py b/backends/arm/test/ops/test_avg_pool.py index 344a80a79bf..afd079fb957 100644 --- a/backends/arm/test/ops/test_avg_pool.py +++ b/backends/arm/test/ops/test_avg_pool.py @@ -55,7 +55,9 @@ def _test_avgpool2d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .check(["torch.ops.aten.avg_pool2d.default"]) @@ -76,7 +78,9 @@ def _test_avgpool2d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_batch_norm.py b/backends/arm/test/ops/test_batch_norm.py index bfe1146a904..297ac0af1c7 100644 --- a/backends/arm/test/ops/test_batch_norm.py +++ b/backends/arm/test/ops/test_batch_norm.py @@ -533,7 +533,7 @@ def _test_batchnorm2d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_not(["torch.ops.quantized_decomposed"]) @@ -561,7 +561,7 @@ def _test_batchnorm2d_no_stats_tosa_MI_pipeline( ArmTester( module, example_example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten._native_batch_norm_legit.no_stats": 1}) @@ -590,7 +590,7 @@ def _test_batchnorm2d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_bmm.py b/backends/arm/test/ops/test_bmm.py index e4e6abb7bb3..e5e9508e250 100644 --- a/backends/arm/test/ops/test_bmm.py +++ b/backends/arm/test/ops/test_bmm.py @@ -50,7 +50,7 @@ def _test_bmm_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.bmm.default": 1}) @@ -70,7 +70,7 @@ def _test_bmm_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_cat.py b/backends/arm/test/ops/test_cat.py index 9723ba0f0c0..b380c44d52f 100644 --- a/backends/arm/test/ops/test_cat.py +++ b/backends/arm/test/ops/test_cat.py @@ -56,7 +56,7 @@ def _test_cat_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.cat.default": 1}) @@ -76,7 +76,7 @@ def _test_cat_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_clone.py b/backends/arm/test/ops/test_clone.py index 9852c5c4520..4721f257b0c 100644 --- a/backends/arm/test/ops/test_clone.py +++ b/backends/arm/test/ops/test_clone.py @@ -47,7 +47,7 @@ def _test_clone_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.clone.default": 1}) @@ -66,7 +66,7 @@ def _test_clone_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_conv1d.py b/backends/arm/test/ops/test_conv1d.py index 3b275542213..133148faef9 100644 --- a/backends/arm/test/ops/test_conv1d.py +++ b/backends/arm/test/ops/test_conv1d.py @@ -226,7 +226,9 @@ def _test_conv1d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .to_edge() @@ -246,7 +248,9 @@ def _test_conv1d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_conv2d.py b/backends/arm/test/ops/test_conv2d.py index 46adfc8a016..43c3e851396 100644 --- a/backends/arm/test/ops/test_conv2d.py +++ b/backends/arm/test/ops/test_conv2d.py @@ -253,7 +253,9 @@ def _test_conv2d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .to_edge() @@ -273,7 +275,9 @@ def _test_conv2d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_conv_combos.py b/backends/arm/test/ops/test_conv_combos.py index 4b45b671268..3e9bdef958c 100644 --- a/backends/arm/test/ops/test_conv_combos.py +++ b/backends/arm/test/ops/test_conv_combos.py @@ -192,7 +192,9 @@ def _test_conv_combo_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .to_edge() @@ -214,7 +216,9 @@ def _test_conv_combo_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_depthwise_conv.py b/backends/arm/test/ops/test_depthwise_conv.py index 01ffbc10543..4bfa863c49f 100644 --- a/backends/arm/test/ops/test_depthwise_conv.py +++ b/backends/arm/test/ops/test_depthwise_conv.py @@ -177,7 +177,9 @@ def _test_dw_conv_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .to_edge() @@ -195,7 +197,9 @@ def _test_dw_conv_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_div.py b/backends/arm/test/ops/test_div.py index 84a8d53f9dd..28cc6866906 100644 --- a/backends/arm/test/ops/test_div.py +++ b/backends/arm/test/ops/test_div.py @@ -102,7 +102,7 @@ def _test_div_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.div.Tensor": 1}) @@ -121,7 +121,7 @@ def _test_div_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_exp.py b/backends/arm/test/ops/test_exp.py index 6e85d8fe49b..c706b7b206d 100644 --- a/backends/arm/test/ops/test_exp.py +++ b/backends/arm/test/ops/test_exp.py @@ -40,7 +40,7 @@ def _test_exp_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.exp.default"]) @@ -58,7 +58,7 @@ def _test_exp_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple): ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_expand.py b/backends/arm/test/ops/test_expand.py index aa13a6475c6..effa7ce713b 100644 --- a/backends/arm/test/ops/test_expand.py +++ b/backends/arm/test/ops/test_expand.py @@ -46,7 +46,7 @@ def _test_expand_tosa_MI_pipeline(self, module: torch.nn.Module, test_data: Tupl ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.expand.default": 1}) @@ -64,7 +64,7 @@ def _test_expand_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tupl ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_full.py b/backends/arm/test/ops/test_full.py index 2722edef328..d4cfc5c3692 100644 --- a/backends/arm/test/ops/test_full.py +++ b/backends/arm/test/ops/test_full.py @@ -57,7 +57,7 @@ def _test_full_tosa_MI_pipeline( ArmTester( module, example_inputs=example_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.full.default": 1}) @@ -80,7 +80,7 @@ def _test_full_tosa_BI_pipeline( module, example_inputs=test_data, compile_spec=common.get_tosa_compile_spec( - permute_memory_to_nhwc=permute_memory_to_nhwc + "TOSA-0.80.0+BI", permute_memory_to_nhwc=permute_memory_to_nhwc ), ) .quantize() diff --git a/backends/arm/test/ops/test_hardtanh.py b/backends/arm/test/ops/test_hardtanh.py index c7c3736e37b..a9f12abdf02 100644 --- a/backends/arm/test/ops/test_hardtanh.py +++ b/backends/arm/test/ops/test_hardtanh.py @@ -52,7 +52,7 @@ def _test_hardtanh_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.hardtanh.default"]) @@ -73,7 +73,7 @@ def _test_hardtanh_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_layer_norm.py b/backends/arm/test/ops/test_layer_norm.py index 0150c20524a..f059d71eba8 100644 --- a/backends/arm/test/ops/test_layer_norm.py +++ b/backends/arm/test/ops/test_layer_norm.py @@ -74,7 +74,9 @@ def _test_layernorm_tosa_MI_pipeline( ArmTester( model=module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .check(["torch.ops.aten.layer_norm.default"]) @@ -93,7 +95,9 @@ def _test_layernorm_tosa_BI_pipeline( ArmTester( model=module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .check_not(["torch.ops.aten.layer_norm.default"]) diff --git a/backends/arm/test/ops/test_linear.py b/backends/arm/test/ops/test_linear.py index 3f68ab0251a..6221af8446a 100644 --- a/backends/arm/test/ops/test_linear.py +++ b/backends/arm/test/ops/test_linear.py @@ -122,7 +122,9 @@ def _test_linear_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=False), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=False + ), ) .export() .check_count({"torch.ops.aten.linear.default": 1}) @@ -141,7 +143,9 @@ def _test_linear_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=False), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=False + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_log.py b/backends/arm/test/ops/test_log.py index 269b7be25f5..847635ea361 100644 --- a/backends/arm/test/ops/test_log.py +++ b/backends/arm/test/ops/test_log.py @@ -40,7 +40,7 @@ def _test_log_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.log.default"]) @@ -58,7 +58,7 @@ def _test_log_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple): ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_logsoftmax.py b/backends/arm/test/ops/test_logsoftmax.py index 2d51588bb3e..5d84fa127fd 100644 --- a/backends/arm/test/ops/test_logsoftmax.py +++ b/backends/arm/test/ops/test_logsoftmax.py @@ -46,7 +46,7 @@ def _test_logsoftmax_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.log_softmax.int"]) @@ -66,7 +66,7 @@ def _test_logsoftmax_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_mean_dim.py b/backends/arm/test/ops/test_mean_dim.py index 68307bcdf16..e8320cf1df3 100644 --- a/backends/arm/test/ops/test_mean_dim.py +++ b/backends/arm/test/ops/test_mean_dim.py @@ -81,7 +81,7 @@ def _test_adaptive_avg_pool2d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.adaptive_avg_pool2d.default"]) @@ -101,7 +101,7 @@ def _test_adaptive_avg_pool2d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() @@ -150,7 +150,7 @@ def _test_meandim_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_not(["torch.ops.quantized_decomposed"]) @@ -169,7 +169,7 @@ def _test_meandim_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_mm.py b/backends/arm/test/ops/test_mm.py index 4271496eaa9..21b02bbd104 100644 --- a/backends/arm/test/ops/test_mm.py +++ b/backends/arm/test/ops/test_mm.py @@ -54,7 +54,7 @@ def _test_mm_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.mm.default": 1}) @@ -74,7 +74,7 @@ def _test_mm_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_mul.py b/backends/arm/test/ops/test_mul.py index a1c2dba5fed..7fa20c25667 100644 --- a/backends/arm/test/ops/test_mul.py +++ b/backends/arm/test/ops/test_mul.py @@ -70,7 +70,9 @@ def _test_mul_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .check_count({"torch.ops.aten.mul.Tensor": 1}) @@ -89,7 +91,9 @@ def _test_mul_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_permute.py b/backends/arm/test/ops/test_permute.py index 6346e847c98..62b6b823de7 100644 --- a/backends/arm/test/ops/test_permute.py +++ b/backends/arm/test/ops/test_permute.py @@ -57,7 +57,7 @@ def _test_permute_tosa_MI_pipeline( module, example_inputs=test_data, compile_spec=common.get_tosa_compile_spec( - permute_memory_to_nhwc=permute_memory_to_nhwc + "TOSA-0.80.0+MI", permute_memory_to_nhwc=permute_memory_to_nhwc ), ) .export() @@ -79,7 +79,7 @@ def _test_permute_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_reciprocal.py b/backends/arm/test/ops/test_reciprocal.py index cb4971bf8c4..7745a614e6b 100644 --- a/backends/arm/test/ops/test_reciprocal.py +++ b/backends/arm/test/ops/test_reciprocal.py @@ -46,7 +46,7 @@ def _test_reciprocal_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.reciprocal.default": 1}) @@ -65,7 +65,7 @@ def _test_reciprocal_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_relu.py b/backends/arm/test/ops/test_relu.py index effbccc74d5..595c907b323 100644 --- a/backends/arm/test/ops/test_relu.py +++ b/backends/arm/test/ops/test_relu.py @@ -48,7 +48,7 @@ def _test_relu_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.relu.default"]) @@ -69,7 +69,7 @@ def _test_relu_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_repeat.py b/backends/arm/test/ops/test_repeat.py index 1efac9f9742..20c57ba749c 100644 --- a/backends/arm/test/ops/test_repeat.py +++ b/backends/arm/test/ops/test_repeat.py @@ -47,7 +47,7 @@ def _test_repeat_tosa_MI_pipeline(self, module: torch.nn.Module, test_data: Tupl ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.repeat.default": 1}) @@ -65,7 +65,7 @@ def _test_repeat_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tupl ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_rsqrt.py b/backends/arm/test/ops/test_rsqrt.py index 2ccb7ec9916..2cddc8da26e 100644 --- a/backends/arm/test/ops/test_rsqrt.py +++ b/backends/arm/test/ops/test_rsqrt.py @@ -35,7 +35,7 @@ def _test_rsqrt_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.rsqrt.default": 1}) @@ -53,7 +53,7 @@ def _test_rsqrt_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_scalars.py b/backends/arm/test/ops/test_scalars.py index 0305ef58c0f..86433745a63 100644 --- a/backends/arm/test/ops/test_scalars.py +++ b/backends/arm/test/ops/test_scalars.py @@ -123,7 +123,7 @@ def _test_add_tosa_MI_pipeline(self, module: torch.nn.Module, test_data: tuple): ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -137,7 +137,7 @@ def _test_add_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: tuple): ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_select.py b/backends/arm/test/ops/test_select.py index fdb2fa14633..85bfc15d2dc 100644 --- a/backends/arm/test/ops/test_select.py +++ b/backends/arm/test/ops/test_select.py @@ -58,7 +58,7 @@ def _test_select_tosa_MI_pipeline( module, example_inputs=test_data, compile_spec=common.get_tosa_compile_spec( - permute_memory_to_nhwc=permute + "TOSA-0.80.0+MI", permute_memory_to_nhwc=permute ), ) .export() @@ -84,7 +84,7 @@ def _test_select_tosa_BI_pipeline( module, example_inputs=test_data, compile_spec=common.get_tosa_compile_spec( - permute_memory_to_nhwc=permute + "TOSA-0.80.0+BI", permute_memory_to_nhwc=permute ), ) .quantize() diff --git a/backends/arm/test/ops/test_sigmoid.py b/backends/arm/test/ops/test_sigmoid.py index 4d126b68e58..f12658c985a 100644 --- a/backends/arm/test/ops/test_sigmoid.py +++ b/backends/arm/test/ops/test_sigmoid.py @@ -71,7 +71,7 @@ def _test_sigmoid_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.sigmoid.default"]) @@ -89,7 +89,7 @@ def _test_sigmoid_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tup ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_slice.py b/backends/arm/test/ops/test_slice.py index 18db358fdf4..0fc92b011a0 100644 --- a/backends/arm/test/ops/test_slice.py +++ b/backends/arm/test/ops/test_slice.py @@ -39,7 +39,7 @@ def _test_slice_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.slice.Tensor"]) @@ -60,7 +60,7 @@ def _test_slice_tosa_BI_pipeline( module, example_inputs=test_data, compile_spec=common.get_tosa_compile_spec( - permute_memory_to_nhwc=permute + "TOSA-0.80.0+BI", permute_memory_to_nhwc=permute ), ) .quantize() diff --git a/backends/arm/test/ops/test_softmax.py b/backends/arm/test/ops/test_softmax.py index 954dd201a9a..f883d6b8deb 100644 --- a/backends/arm/test/ops/test_softmax.py +++ b/backends/arm/test/ops/test_softmax.py @@ -47,7 +47,7 @@ def _test_softmax_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.softmax.int"]) @@ -67,7 +67,7 @@ def _test_softmax_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_split.py b/backends/arm/test/ops/test_split.py index 8ed0e723f18..42395c4c2d8 100644 --- a/backends/arm/test/ops/test_split.py +++ b/backends/arm/test/ops/test_split.py @@ -56,7 +56,7 @@ def _test_split_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -79,7 +79,7 @@ def _test_split_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_squeeze.py b/backends/arm/test/ops/test_squeeze.py index c3f1edf37be..7e915da645d 100644 --- a/backends/arm/test/ops/test_squeeze.py +++ b/backends/arm/test/ops/test_squeeze.py @@ -61,7 +61,7 @@ def _test_squeeze_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({export_target: 1}) @@ -82,7 +82,7 @@ def _test_squeeze_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_sub.py b/backends/arm/test/ops/test_sub.py index e80c0436989..5c67240e521 100644 --- a/backends/arm/test/ops/test_sub.py +++ b/backends/arm/test/ops/test_sub.py @@ -43,7 +43,7 @@ def _test_sub_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.sub.Tensor": 1}) @@ -63,7 +63,7 @@ def _test_sub_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_sum.py b/backends/arm/test/ops/test_sum.py index 73860dfa4af..9cd63b0a22e 100644 --- a/backends/arm/test/ops/test_sum.py +++ b/backends/arm/test/ops/test_sum.py @@ -49,7 +49,7 @@ def _test_sum_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.sum.dim_IntList": 1}) @@ -68,7 +68,7 @@ def _test_sum_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_tanh.py b/backends/arm/test/ops/test_tanh.py index 6f5cf17cf30..5f3859eadd9 100644 --- a/backends/arm/test/ops/test_tanh.py +++ b/backends/arm/test/ops/test_tanh.py @@ -44,7 +44,7 @@ def _test_tanh_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check(["torch.ops.aten.tanh.default"]) @@ -62,7 +62,7 @@ def _test_tanh_tosa_BI_pipeline(self, module: torch.nn.Module, test_data: Tuple) ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_unsqueeze.py b/backends/arm/test/ops/test_unsqueeze.py index 36bb93b7960..8936d55f8bf 100644 --- a/backends/arm/test/ops/test_unsqueeze.py +++ b/backends/arm/test/ops/test_unsqueeze.py @@ -35,7 +35,7 @@ def _test_unsqueeze_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.unsqueeze.default": 1}) @@ -53,7 +53,7 @@ def _test_unsqueeze_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/ops/test_var.py b/backends/arm/test/ops/test_var.py index 56b7c5fbb41..3a1285e6daf 100644 --- a/backends/arm/test/ops/test_var.py +++ b/backends/arm/test/ops/test_var.py @@ -86,7 +86,7 @@ def _test_var_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .to_edge() @@ -107,7 +107,7 @@ def _test_var_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export() diff --git a/backends/arm/test/ops/test_view.py b/backends/arm/test/ops/test_view.py index 54e80702e39..09a8f57bd39 100644 --- a/backends/arm/test/ops/test_view.py +++ b/backends/arm/test/ops/test_view.py @@ -55,7 +55,7 @@ def _test_view_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+MI"), ) .export() .check_count({"torch.ops.aten.view.default": 1}) @@ -73,7 +73,7 @@ def _test_view_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/passes/test_meandim_to_averagepool2d.py b/backends/arm/test/passes/test_meandim_to_averagepool2d.py index c8fa0f4b7ab..615187fb65d 100644 --- a/backends/arm/test/passes/test_meandim_to_averagepool2d.py +++ b/backends/arm/test/passes/test_meandim_to_averagepool2d.py @@ -46,7 +46,7 @@ def test_tosa_BI_meandim_to_averagepool(self): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() @@ -63,7 +63,7 @@ def test_tosa_BI_meandim_no_modification(self): ArmTester( module, example_inputs=module.get_inputs(), - compile_spec=common.get_tosa_compile_spec(), + compile_spec=common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) .quantize() .export() diff --git a/backends/arm/test/quantizer/test_generic_annotater.py b/backends/arm/test/quantizer/test_generic_annotater.py index b859757df4b..3d39463a424 100644 --- a/backends/arm/test/quantizer/test_generic_annotater.py +++ b/backends/arm/test/quantizer/test_generic_annotater.py @@ -30,7 +30,9 @@ def example_inputs(self): class TestGenericAnnotator(unittest.TestCase): def check_annotation(self, model): tester = ArmTester( - model, model.example_inputs(), common.get_tosa_compile_spec() + model, + model.example_inputs(), + common.get_tosa_compile_spec("TOSA-0.80.0+BI"), ) quant_model = tester.quantize().get_artifact() partitions = get_source_partitions(quant_model.graph, [model.op]) From 371bcfd16f79f626ceefb6784b98adf753778739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Thu, 17 Oct 2024 13:57:56 +0200 Subject: [PATCH 4/5] Adapt ADD serialization to use TOSA Specification handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds handling of TOSA 0.80 BI and MI profile as separate serialization handlers for ADD as an example. Signed-off-by: Per Åstrand Change-Id: I89e8ded90ec29bfca06a0ab9a102307cd0b005bd --- backends/arm/operators/op_add.py | 73 ++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/backends/arm/operators/op_add.py b/backends/arm/operators/op_add.py index ec2ade9e8ad..d0518c7a5eb 100644 --- a/backends/arm/operators/op_add.py +++ b/backends/arm/operators/op_add.py @@ -11,19 +11,25 @@ import executorch.backends.arm.tosa_utils as tutils import serializer.tosa_serializer as ts +import torch from executorch.backends.arm.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.arm.tosa_mapping import TosaArg +from executorch.backends.arm.tosa_specification import TosaSpecification from serializer.tosa_serializer import TosaOp from torch.fx import Node @register_node_visitor -class AddVisitor(NodeVisitor): +class AddVisitor_080_BI(NodeVisitor): target = "aten.add.Tensor" + tosa_specs = [ + TosaSpecification.create_from_string("TOSA-0.80.0+BI"), + ] + def __init__(self, *args): super().__init__(*args) @@ -35,9 +41,22 @@ def define_node( output: TosaArg, is_quant_node: bool, ) -> None: - if is_quant_node: - input_nodes = tutils.get_two_inputs(node) + input_nodes = tutils.get_two_inputs(node) + + if not is_quant_node and not all( + tensor.meta["val"].dtype in (torch.int8, torch.int32) + for tensor in input_nodes + ): + raise RuntimeError( + f"Unexpected non quantized {AddVisitor_080_BI.target} node." + ) + needs_rescale = not ( + all(tensor.meta["val"].dtype == torch.int32 for tensor in input_nodes) + and node.meta["val"].dtype == torch.int32 + ) + + if needs_rescale: # Rescale inputs to 32 bit rescaled_inputs, scale = tqutils.rescale_nodes_to_int32( input_nodes, tosa_graph @@ -48,20 +67,48 @@ def define_node( rescaled_inputs[0].shape, rescaled_inputs[0].shape ) add_output = tosa_graph.addIntermediate(broadcasted_shape, ts.DType.INT32) + else: + add_output = output + rescaled_inputs = inputs - # Do the INT32 Add - tosa_graph.addOperator( - TosaOp.Op().ADD, - [ - rescaled_inputs[0].name, - rescaled_inputs[1].name, - ], - [add_output.name], - None, - ) + # Do the INT32 Add + tosa_graph.addOperator( + TosaOp.Op().ADD, + [ + rescaled_inputs[0].name, + rescaled_inputs[1].name, + ], + [add_output.name], + None, + ) + if needs_rescale: # Scale output back to 8 bit tqutils.rescale_node_back_to_int8(node, add_output, scale, tosa_graph) + + +@register_node_visitor +class AddVisitor_080_MI(AddVisitor_080_BI): + # inheriting 'target' from BI class + + tosa_specs = [ + TosaSpecification.create_from_string("TOSA-0.80.0+MI"), + ] + + def __init__(self, *args): + super().__init__(*args) + + def define_node( + self, + node: Node, + tosa_graph: ts.TosaSerializer, + inputs: List[TosaArg], + output: TosaArg, + is_quant_node: bool, + ) -> None: + if is_quant_node: + # Call the inherited define_node for handling integers + super().define_node(node, tosa_graph, inputs, output, is_quant_node) else: # FP32 Add lowering tosa_graph.addOperator( From 51dc602e0ebb82c10c3b1925d0300a070b516885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Thu, 7 Nov 2024 08:36:30 +0100 Subject: [PATCH 5/5] Add TOSA version string to max_pool tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Per Åstrand Change-Id: I14ce1d9f53396d3ff49536875f24dabd24a71c10 --- backends/arm/test/ops/test_max_pool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backends/arm/test/ops/test_max_pool.py b/backends/arm/test/ops/test_max_pool.py index 5c48afa3ce1..41526b1c776 100644 --- a/backends/arm/test/ops/test_max_pool.py +++ b/backends/arm/test/ops/test_max_pool.py @@ -62,7 +62,9 @@ def _test_maxpool2d_tosa_MI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+MI", permute_memory_to_nhwc=True + ), ) .export() .check(["torch.ops.aten.max_pool2d.default"]) @@ -87,7 +89,9 @@ def _test_maxpool2d_tosa_BI_pipeline( ArmTester( module, example_inputs=test_data, - compile_spec=common.get_tosa_compile_spec(permute_memory_to_nhwc=True), + compile_spec=common.get_tosa_compile_spec( + "TOSA-0.80.0+BI", permute_memory_to_nhwc=True + ), ) .quantize(Quantize(quantizer, get_symmetric_quantization_config())) .export()