1- # Copyright 2023-2024 Arm Limited and/or its affiliates.
1+ # Copyright 2023-2025 Arm Limited and/or its affiliates.
22#
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.
@@ -49,8 +49,6 @@ def __init__(self):
4949 self .compiler_flags = []
5050 self .output_format = None
5151 self .path_for_intermediates = None
52- # TODO MLETORCH-265 Remove permute_nhwc flag
53- self .permute_nhwc = False
5452 self .quantize_io = False
5553 self .tosa_version = None
5654 self .input_order = None
@@ -118,16 +116,6 @@ def dump_intermediate_artifacts_to(
118116 self .path_for_intermediates = output_path
119117 return self
120118
121- def set_permute_memory_format (
122- self , set_nhwc_permutation : bool = True
123- ) -> "ArmCompileSpecBuilder" :
124- """
125- Permute to channel last in compiler and runtime. Compilation and
126- runtime will convert rank 4 inputs to channel last for each sub-graph.
127- """
128- self .permute_nhwc = set_nhwc_permutation
129- return self
130-
131119 def set_quantize_io (self , quantize_io : bool = False ) -> "ArmCompileSpecBuilder" :
132120 """
133121 Quantization of inputs and dequantization of outputs for cases where
@@ -170,11 +158,6 @@ def build(self) -> List[CompileSpec]:
170158 CompileSpec ("debug_artifact_path" , self .path_for_intermediates .encode ())
171159 )
172160
173- if self .permute_nhwc :
174- self .compile_spec .append (
175- CompileSpec ("permute_memory_format" , "nhwc" .encode ())
176- )
177-
178161 if self .input_order :
179162 self .compile_spec .append (
180163 CompileSpec (
@@ -188,20 +171,27 @@ def build(self) -> List[CompileSpec]:
188171 return self .compile_spec
189172
190173
191- def is_permute_memory (compile_spec : List [CompileSpec ]) -> bool :
192- for spec in compile_spec :
193- if spec .key == "permute_memory_format" :
194- return spec .value .decode () == "nhwc"
195- return False
196-
197-
198174def is_tosa (compile_spec : List [CompileSpec ]) -> bool :
199175 for spec in compile_spec :
200176 if spec .key == "output_format" :
201177 return spec .value .decode () == "tosa"
202178 return False
203179
204180
181+ def is_quantize_io (compile_specs : List [CompileSpec ]) -> bool :
182+ for spec in compile_specs :
183+ if spec .key == "quantize_io" and spec .value .decode () == "True" :
184+ return True
185+ return False
186+
187+
188+ def get_tosa_version (compile_spec : List [CompileSpec ]) -> TosaSpecification :
189+ for spec in compile_spec :
190+ if spec .key == "tosa_version" :
191+ return TosaSpecification .create_from_string (spec .value .decode ())
192+ raise RuntimeError ("Could not find TOSA version in CompileSpec" )
193+
194+
205195def get_intermediate_path (compile_spec : List [CompileSpec ]) -> Optional [str ]:
206196 for spec in compile_spec :
207197 if spec .key == "debug_artifact_path" :
@@ -264,7 +254,7 @@ def preprocess( # noqa: C901
264254 # const data directly. Path created and data written only in debug builds.
265255 tosa_graph = ts .TosaSerializer (artifact_path )
266256 graph_module = ArmPassManager ().transform_to_backend_pipeline (
267- exported_program = edge_program , compile_spec = compile_spec
257+ exported_program = edge_program
268258 )
269259
270260 node_visitors = get_node_visitors (edge_program , tosa_spec )
0 commit comments