-
Notifications
You must be signed in to change notification settings - Fork 971
Arm backend: Move to sha-1 on main branch for tosa-tools #18841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ class DebugMode(Enum): | |
| compiler_flags: list[str] = field(default_factory=list) | ||
| path_for_intermediates: str | None = None | ||
| tosa_debug_mode: DebugMode | None = None | ||
| tosa_dev_mode: bool | None = None | ||
|
|
||
| _TOSA_SPEC_KEY = "tosa_spec" | ||
| _COMPILE_FLAGS_KEY = "compile_flags" | ||
|
|
@@ -44,6 +45,7 @@ class DebugMode(Enum): | |
| _DEBUG_MODE_KEY = "dump_debug_info" | ||
| _OUTPUT_REORDER_KEY = "ouput_reorder_workaround" | ||
| _TRANSFORM_PIPELINE_CONFIG_KEY = "transform_pipeline_config" | ||
| _TOSA_DEV_MODE = "tosa_sw_dev_mode" | ||
|
|
||
| def _set_compile_specs( | ||
| self, | ||
|
|
@@ -53,6 +55,7 @@ def _set_compile_specs( | |
| tosa_debug_mode: DebugMode | None = None, | ||
| output_order_workaround: bool = False, | ||
| pipeline_config: ArmPassPipelineConfig | None = None, | ||
| tosa_dev_mode: bool | None = None, | ||
| ): | ||
| """Set all values of dataclass directly.""" | ||
| self.tosa_spec = tosa_spec | ||
|
|
@@ -61,6 +64,7 @@ def _set_compile_specs( | |
| self.tosa_debug_mode = tosa_debug_mode | ||
| self._pipeline_config = pipeline_config | ||
| self.output_order_workaround = output_order_workaround | ||
| self.tosa_dev_mode = tosa_dev_mode | ||
| if output_order_workaround: | ||
| warnings.warn( | ||
| "ArmCompileSpec(output_order_workaround=True) is deprecated and will be " | ||
|
|
@@ -78,6 +82,7 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901 | |
| tosa_debug_mode: ArmCompileSpec.DebugMode | None = None | ||
| output_order_workaround: bool = False | ||
| pipeline_config: ArmPassPipelineConfig | None = None | ||
| tosa_dev_mode: bool | None = None | ||
| unknown_specs: dict[str, str] = {} | ||
| for spec in compile_specs: | ||
| key = spec.key | ||
|
|
@@ -128,6 +133,20 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901 | |
| "More than one transform pipeline entry in compile spec." | ||
| ) | ||
| pipeline_config = ArmPassPipelineConfig.from_dict(json.loads(val)) | ||
| elif key == ArmCompileSpec._TOSA_DEV_MODE: | ||
| if tosa_dev_mode is not None: | ||
| raise ValueError( | ||
| "More than one tosa_sw_dev_mode entry in compile spec." | ||
| ) | ||
| raw = bytes(spec.value) | ||
| if raw == b"\x01": | ||
| tosa_dev_mode = True | ||
| elif raw == b"\x00": | ||
| tosa_dev_mode = False | ||
| else: | ||
| raise ValueError( | ||
| f"Invalid tosa_sw_dev_mode byte value: {raw!r}, expected b'\\x00' or b'\\x01'." | ||
| ) | ||
| else: | ||
| unknown_specs[key] = val | ||
|
|
||
|
|
@@ -151,6 +170,7 @@ def _from_list(cls, compile_specs: list[CompileSpec]): # noqa: C901 | |
| tosa_debug_mode=tosa_debug_mode, | ||
| output_order_workaround=output_order_workaround, | ||
| pipeline_config=pipeline_config, | ||
| tosa_dev_mode=tosa_dev_mode, | ||
| ) | ||
| cls._from_list_hook(compile_spec, unknown_specs) | ||
| compile_spec._validate() | ||
|
|
@@ -227,6 +247,15 @@ def _to_list(self): | |
| self._pipeline_config.serialize(), | ||
| ) | ||
| ) | ||
|
|
||
| if self.tosa_dev_mode is not None: | ||
| compile_spec.append( | ||
| CompileSpec( | ||
| ArmCompileSpec._TOSA_DEV_MODE, | ||
| b"\x01" if self.tosa_dev_mode else b"\x00", | ||
| ) | ||
| ) | ||
|
|
||
| return compile_spec | ||
|
|
||
| def _get_pass_pipeline_config(self) -> ArmPassPipelineConfig: | ||
|
|
@@ -290,6 +319,16 @@ def dump_debug_info(self, debug_mode: DebugMode | None): | |
| self.tosa_debug_mode = debug_mode | ||
| return self | ||
|
|
||
| def _set_tosa_dev_mode(self, tosa_dev_mode: bool): | ||
| """Sets whether to enable TOSA software development mode. | ||
|
|
||
| Args: | ||
| tosa_dev_mode: Boolean indicating whether to enable TOSA software development mode. | ||
|
|
||
| """ | ||
| self.tosa_dev_mode = tosa_dev_mode | ||
| return self | ||
|
Comment on lines
+322
to
+330
|
||
|
|
||
| @deprecated( | ||
| "set_output_order_workaround() is deprecated and will be removed in v1.5; please remove this call." | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,9 @@ def _preprocess( # noqa: C901 | |
| targetDraft=True if version.minor > 0 else False, | ||
| ) | ||
|
|
||
| if compile_spec.tosa_dev_mode: | ||
| tosa_graph.setExperimentalDevVersion() | ||
|
|
||
| if not ( | ||
| tosa_spec.version.major == ts.TOSA_VERSION_MAJOR | ||
| and tosa_spec.version.minor <= ts.TOSA_VERSION_MINOR | ||
|
|
@@ -440,4 +443,5 @@ def filter_tosa_compile_specs( | |
| ) | ||
| .dump_debug_info(compile_spec.tosa_debug_mode) | ||
| .set_output_order_workaround(compile_spec.output_order_workaround) | ||
| ._set_tosa_dev_mode(compile_spec.tosa_dev_mode) | ||
| ) | ||
|
Comment on lines
443
to
447
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant naming is inconsistent with the other compile-spec keys (
_TOSA_SPEC_KEY,_COMPILE_FLAGS_KEY, ...). Consider renaming_TOSA_DEV_MODEto_TOSA_DEV_MODE_KEY(and updating references) to match the established pattern.