@@ -35,19 +35,22 @@ class DebugMode(Enum):
3535 _OUTPUT_FORMAT_KEY = "output_format"
3636 _DEBUG_ARTIFACT_KEY = "debug_artifact_path"
3737 _DEBUG_MODE_KEY = "dump_debug_info"
38+ _OUTPUT_REORDER_KEY = "ouput_reorder_workaround"
3839
3940 def _set_compile_specs (
4041 self ,
4142 tosa_spec : TosaSpecification ,
4243 compiler_flags : list [str ],
4344 path_for_intermediates : str | None = None ,
4445 tosa_debug_mode : DebugMode | None = None ,
46+ output_order_workaround : bool = True ,
4547 ):
4648 """Set all values of dataclass directly."""
4749 self .tosa_spec = tosa_spec
4850 self .compiler_flags = compiler_flags
4951 self .path_for_intermediates = path_for_intermediates
5052 self .tosa_debug_mode = tosa_debug_mode
53+ self .output_order_workaround = output_order_workaround
5154
5255 @classmethod
5356 def from_list (cls , compile_specs : list [CompileSpec ]): # noqa: C901
@@ -56,10 +59,15 @@ def from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
5659 compiler_flags : list [str ] | None = None
5760 path_for_intermediates : str | None = None
5861 tosa_debug_mode : ArmCompileSpec .DebugMode | None = None
62+ output_order_workaround : bool = True
5963 unknown_specs : dict [str , str ] = {}
6064 for spec in compile_specs :
6165 key = spec .key
62- val = spec .value .decode ()
66+ val = (
67+ spec .value .decode ()
68+ if isinstance (spec .value , (bytes , bytearray ))
69+ else spec .value
70+ )
6371 if key == ArmCompileSpec ._TOSA_SPEC_KEY :
6472 if tosa_spec is not None :
6573 raise ValueError ("More than one tosa_spec entry in compile spec." )
@@ -88,6 +96,8 @@ def from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
8896 "More than one tosa_debug_mode entry in compile spec."
8997 )
9098 tosa_debug_mode = ArmCompileSpec .DebugMode [val ]
99+ elif key == ArmCompileSpec ._OUTPUT_REORDER_KEY :
100+ output_order_workaround = val # type: ignore[assignment]
91101 else :
92102 unknown_specs [key ] = val
93103
@@ -109,6 +119,7 @@ def from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
109119 compiler_flags = compiler_flags ,
110120 path_for_intermediates = path_for_intermediates ,
111121 tosa_debug_mode = tosa_debug_mode ,
122+ output_order_workaround = output_order_workaround ,
112123 )
113124 cls .from_list_hook (compile_spec , unknown_specs )
114125 compile_spec .validate ()
@@ -170,6 +181,14 @@ def to_list(self):
170181 )
171182 )
172183
184+ if not self .output_order_workaround :
185+ compile_spec .append (
186+ CompileSpec (
187+ ArmCompileSpec ._OUTPUT_REORDER_KEY ,
188+ self .output_order_workaround ,
189+ )
190+ )
191+
173192 return compile_spec
174193
175194 def get_intermediate_path (self ) -> str | None :
@@ -201,6 +220,13 @@ def dump_debug_info(self, debug_mode: DebugMode | None):
201220 self .tosa_debug_mode = debug_mode
202221 return self
203222
223+ def set_output_order_workaround (self , output_order_workaround : bool ):
224+ self .output_order_workaround = output_order_workaround
225+ return self
226+
227+ def get_output_order_workaround (self ) -> bool :
228+ return self .output_order_workaround
229+
204230 @classmethod
205231 @abstractmethod
206232 def get_output_format (cls ) -> str :
0 commit comments