Skip to content

Commit

Permalink
Remove redundant generate_*_compile_spec funcs
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Elliott <[email protected]>
  • Loading branch information
robell committed Jul 26, 2024
1 parent f32d707 commit 72e4dab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
37 changes: 0 additions & 37 deletions backends/arm/arm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,43 +166,6 @@ def get_intermediate_path(compile_spec: List[CompileSpec]) -> str:
return None


def generate_ethosu_compile_spec(
config: str,
permute_memory_to_nhwc: Optional[bool] = None,
quantize_io: Optional[bool] = None,
system_config: Optional[str] = None,
memory_mode: Optional[str] = None,
extra_flags: Optional[str] = None,
config_ini: Optional[str] = "Arm/vela.ini",
) -> List[CompileSpec]:
return (
ArmCompileSpecBuilder()
.ethosu_compile_spec(
config,
system_config=system_config,
memory_mode=memory_mode,
extra_flags=extra_flags,
config_ini=config_ini,
)
.set_permute_memory_format(permute_memory_to_nhwc)
.set_quantize_io(quantize_io)
.build()
)


def generate_tosa_compile_spec(
permute_memory_to_nhwc: Optional[bool] = None,
output_path: Optional[str] = None,
) -> List[CompileSpec]:
return (
ArmCompileSpecBuilder()
.tosa_compile_spec()
.set_permute_memory_format(permute_memory_to_nhwc)
.dump_intermediate_artifacts_to(output_path)
.build()
)


@final
class ArmBackend(BackendDetails):
@staticmethod
Expand Down
14 changes: 8 additions & 6 deletions examples/arm/aot_arm_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import logging

import torch
from executorch.backends.arm.arm_backend import generate_ethosu_compile_spec

from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder
from executorch.backends.arm.arm_partitioner import ArmPartitioner
from executorch.backends.arm.quantizer.arm_quantizer import (
ArmQuantizer,
Expand Down Expand Up @@ -212,12 +213,13 @@ def forward(self, x):
if args.delegate is True:
edge = edge.to_backend(
ArmPartitioner(
generate_ethosu_compile_spec(
"ethos-u55-128",
permute_memory_to_nhwc=args.model_name
in MODEL_NAME_TO_MODEL.keys(),
quantize_io=True,
ArmCompileSpecBuilder()
.ethosu_compile_spec("ethos-u55-128")
.set_permute_memory_format(
args.model_name in MODEL_NAME_TO_MODEL.keys()
)
.set_quantize_io(True)
.build()
)
)
logging.debug(f"Lowered graph:\n{edge.exported_program().graph}")
Expand Down

0 comments on commit 72e4dab

Please sign in to comment.