@@ -36,6 +36,7 @@ class DebugMode(Enum):
3636 compiler_flags : list [str ] = field (default_factory = list )
3737 path_for_intermediates : str | None = None
3838 tosa_debug_mode : DebugMode | None = None
39+ tosa_dev_mode : bool | None = None
3940
4041 _TOSA_SPEC_KEY = "tosa_spec"
4142 _COMPILE_FLAGS_KEY = "compile_flags"
@@ -44,6 +45,7 @@ class DebugMode(Enum):
4445 _DEBUG_MODE_KEY = "dump_debug_info"
4546 _OUTPUT_REORDER_KEY = "ouput_reorder_workaround"
4647 _TRANSFORM_PIPELINE_CONFIG_KEY = "transform_pipeline_config"
48+ _TOSA_DEV_MODE = "tosa_sw_dev_mode"
4749
4850 def _set_compile_specs (
4951 self ,
@@ -53,6 +55,7 @@ def _set_compile_specs(
5355 tosa_debug_mode : DebugMode | None = None ,
5456 output_order_workaround : bool = False ,
5557 pipeline_config : ArmPassPipelineConfig | None = None ,
58+ tosa_dev_mode : bool | None = None ,
5659 ):
5760 """Set all values of dataclass directly."""
5861 self .tosa_spec = tosa_spec
@@ -61,6 +64,7 @@ def _set_compile_specs(
6164 self .tosa_debug_mode = tosa_debug_mode
6265 self ._pipeline_config = pipeline_config
6366 self .output_order_workaround = output_order_workaround
67+ self .tosa_dev_mode = tosa_dev_mode
6468 if output_order_workaround :
6569 warnings .warn (
6670 "ArmCompileSpec(output_order_workaround=True) is deprecated and will be "
@@ -78,6 +82,7 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
7882 tosa_debug_mode : ArmCompileSpec .DebugMode | None = None
7983 output_order_workaround : bool = False
8084 pipeline_config : ArmPassPipelineConfig | None = None
85+ tosa_dev_mode : bool | None = None
8186 unknown_specs : dict [str , str ] = {}
8287 for spec in compile_specs :
8388 key = spec .key
@@ -128,6 +133,20 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
128133 "More than one transform pipeline entry in compile spec."
129134 )
130135 pipeline_config = ArmPassPipelineConfig .from_dict (json .loads (val ))
136+ elif key == ArmCompileSpec ._TOSA_DEV_MODE :
137+ if tosa_dev_mode is not None :
138+ raise ValueError (
139+ "More than one tosa_sw_dev_mode entry in compile spec."
140+ )
141+ raw = bytes (spec .value )
142+ if raw == b"\x01 " :
143+ tosa_dev_mode = True
144+ elif raw == b"\x00 " :
145+ tosa_dev_mode = False
146+ else :
147+ raise ValueError (
148+ f"Invalid tosa_sw_dev_mode byte value: { raw !r} , expected b'\\ x00' or b'\\ x01'."
149+ )
131150 else :
132151 unknown_specs [key ] = val
133152
@@ -151,6 +170,7 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901
151170 tosa_debug_mode = tosa_debug_mode ,
152171 output_order_workaround = output_order_workaround ,
153172 pipeline_config = pipeline_config ,
173+ tosa_dev_mode = tosa_dev_mode ,
154174 )
155175 cls ._from_list_hook (compile_spec , unknown_specs )
156176 compile_spec ._validate ()
@@ -227,6 +247,15 @@ def _to_list(self):
227247 self ._pipeline_config .serialize (),
228248 )
229249 )
250+
251+ if self .tosa_dev_mode is not None :
252+ compile_spec .append (
253+ CompileSpec (
254+ ArmCompileSpec ._TOSA_DEV_MODE ,
255+ b"\x01 " if self .tosa_dev_mode else b"\x00 " ,
256+ )
257+ )
258+
230259 return compile_spec
231260
232261 def _get_pass_pipeline_config (self ) -> ArmPassPipelineConfig :
@@ -290,6 +319,16 @@ def dump_debug_info(self, debug_mode: DebugMode | None):
290319 self .tosa_debug_mode = debug_mode
291320 return self
292321
322+ def _set_tosa_dev_mode (self , tosa_dev_mode : bool ):
323+ """Sets whether to enable TOSA software development mode.
324+
325+ Args:
326+ tosa_dev_mode: Boolean indicating whether to enable TOSA software development mode.
327+
328+ """
329+ self .tosa_dev_mode = tosa_dev_mode
330+ return self
331+
293332 @deprecated (
294333 "set_output_order_workaround() is deprecated and will be removed in v1.5; please remove this call."
295334 )
0 commit comments