1010# backends. Converts via TOSA as an intermediate form supported by AoT and
1111# JIT compiler flows.
1212#
13-
1413from typing import List , Optional
1514
16- from executorch .backends .arm .tosa_specification import TosaSpecification
15+ from executorch .backends .arm .tosa_specification import ( # type: ignore[import-not-found]
16+ TosaSpecification ,
17+ )
1718
18- from executorch .exir .backend .compile_spec_schema import CompileSpec
19+ from executorch .exir .backend .compile_spec_schema import ( # type: ignore[import-not-found]
20+ CompileSpec ,
21+ )
1922
2023
2124class ArmCompileSpecBuilder :
@@ -28,6 +31,7 @@ def __init__(self):
2831
2932 def vgf_compile_spec (
3033 self ,
34+ tosa_spec : TosaSpecification = None , # type: ignore[assignment]
3135 compiler_flags : Optional [str ] = "" ,
3236 ) -> "ArmCompileSpecBuilder" :
3337 """
@@ -40,7 +44,33 @@ def vgf_compile_spec(
4044 self .compiler_flags = [
4145 compiler_flags ,
4246 ]
43- self .tosa_spec = TosaSpecification .create_from_string ("TOSA-0.80+MI" )
47+
48+ if tosa_spec is None :
49+ tosa_spec = TosaSpecification .create_from_string ("TOSA-1.0+FP" )
50+
51+ tosa_version = tosa_spec .version # type: ignore[attr-defined]
52+ tosa_profiles = tosa_spec .profiles # type: ignore[attr-defined]
53+
54+ if tosa_version .major != 1 :
55+ raise ValueError (
56+ "Arm backend only supports converter-backend for TOSA version 1. "
57+ f"Invalid TOSA version: { tosa_version } "
58+ )
59+
60+ if not ("FP" or "INT" in tosa_profiles ):
61+ raise ValueError (
62+ "Arm backend only supports converter-backend for FP or INT. "
63+ f"Invalid TOSA profile: { tosa_profiles } "
64+ )
65+
66+ if len (tosa_profiles ) != 1 :
67+ raise ValueError (
68+ "For now Arm backend only supports converter-backend for either FP or INT. "
69+ f"Invalid TOSA profile: { tosa_profiles } "
70+ )
71+
72+ self .tosa_spec = tosa_spec
73+
4474 return self
4575
4676 def ethosu_compile_spec (
0 commit comments