1515from typing import final , List
1616
1717from executorch .backends .arm .arm_vela import vela_compile
18+ from executorch .backends .arm .ethosu .compile_spec import EthosUCompileSpec
1819
1920from executorch .backends .arm .tosa .backend import TOSABackend
2021from executorch .exir .backend .backend_details import BackendDetails , PreprocessResult
@@ -35,16 +36,13 @@ class EthosUBackend(BackendDetails):
3536
3637 @staticmethod
3738 def _compile_tosa_flatbuffer (
38- tosa_flatbuffer : bytes , compile_spec : List [ CompileSpec ]
39+ tosa_flatbuffer : bytes , compile_spec : EthosUCompileSpec
3940 ) -> bytes :
4041 """
4142 Static helper method to do the compilation of the TOSA flatbuffer
4243 representation to a target specific binary stream.
4344 """
44- compile_flags = []
45- for spec in compile_spec :
46- if spec .key == "compile_flags" :
47- compile_flags .append (spec .value .decode ())
45+ compile_flags = compile_spec .compiler_flags
4846
4947 if len (compile_flags ) == 0 :
5048 # Not testing for compile_flags correctness here, just that they are
@@ -64,10 +62,11 @@ def _compile_tosa_flatbuffer(
6462 @staticmethod
6563 def preprocess (
6664 edge_program : ExportedProgram ,
67- compile_spec : List [CompileSpec ],
65+ compile_specs : List [CompileSpec ],
6866 ) -> PreprocessResult :
6967 logger .info (f"{ EthosUBackend .__name__ } preprocess" )
7068
69+ compile_spec = EthosUCompileSpec .from_list (compile_specs )
7170 # deduce TOSA compile_spec from Ethos-U compile spec. We get a new
7271 # compile spec list, containing only elements relevant for the
7372 # TOSABackend.
@@ -77,7 +76,7 @@ def preprocess(
7776 # ('All backend implementation are final...'), so use composition instead.
7877 # preprocess returns the serialized TOSA flatbuffer in .processed_bytes,
7978 # which can be passed on to next compilation step.
80- tosa_preprocess = TOSABackend .preprocess (edge_program , tosa_compile_spec )
79+ tosa_preprocess = TOSABackend ._preprocess (edge_program , tosa_compile_spec )
8180
8281 binary = EthosUBackend ._compile_tosa_flatbuffer (
8382 tosa_preprocess .processed_bytes , compile_spec
0 commit comments