10
10
# backends. Converts via TOSA as an intermediate form supported by AoT and
11
11
# JIT compiler flows.
12
12
#
13
-
14
13
from typing import List , Optional
15
14
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
+ )
17
18
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
+ )
19
22
20
23
21
24
class ArmCompileSpecBuilder :
@@ -28,6 +31,7 @@ def __init__(self):
28
31
29
32
def vgf_compile_spec (
30
33
self ,
34
+ tosa_spec : TosaSpecification = None , # type: ignore[assignment]
31
35
compiler_flags : Optional [str ] = "" ,
32
36
) -> "ArmCompileSpecBuilder" :
33
37
"""
@@ -40,7 +44,33 @@ def vgf_compile_spec(
40
44
self .compiler_flags = [
41
45
compiler_flags ,
42
46
]
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
+
44
74
return self
45
75
46
76
def ethosu_compile_spec (
0 commit comments