20
20
from executorch .exir .backend .compile_spec_schema import CompileSpec
21
21
22
22
SKIP_COMPILE_SPEC_KEYS = {"ImportForever" }
23
+ REQUIRED_COMPILE_SPEC_KEYS = {"platform-config" }
24
+ SUPPORTED_PLATFORM_CONFIGS = {"mt6989" , "mt6991" }
23
25
24
26
25
27
@final
@@ -30,6 +32,28 @@ def preprocess(
30
32
cls , edge_program : ExportedProgram , module_compile_spec : List [CompileSpec ]
31
33
) -> PreprocessResult :
32
34
35
+ # Validate CompileSpec settings
36
+ compile_spec_keys = [spec .key for spec in module_compile_spec ]
37
+ if len (compile_spec_keys ) != len (set (compile_spec_keys )):
38
+ raise RuntimeError (
39
+ "Unsupported duplicated keys in the CompileSpec settings."
40
+ )
41
+ if not REQUIRED_COMPILE_SPEC_KEYS .issubset (set (compile_spec_keys )):
42
+ raise RuntimeError (
43
+ "Following keys are required in the CompileSpec settings: {}."
44
+ "" .format (REQUIRED_COMPILE_SPEC_KEYS )
45
+ )
46
+ platform = [
47
+ spec .value .decode ("utf-8" )
48
+ for spec in module_compile_spec
49
+ if spec .key == "platform-config"
50
+ ][0 ]
51
+ if platform not in SUPPORTED_PLATFORM_CONFIGS :
52
+ raise ValueError (
53
+ "Unsupported value of platform-config CompileSpec. Given {} but expected to be one "
54
+ "of {}." .format (platform , SUPPORTED_PLATFORM_CONFIGS )
55
+ )
56
+
33
57
name_to_node_mappings = {node .name : node for node in edge_program .graph .nodes }
34
58
input_names = edge_program .graph_signature .user_inputs
35
59
output_names = edge_program .graph_signature .user_outputs
@@ -44,8 +68,7 @@ def preprocess(
44
68
if name_to_node_mappings [name ].meta ["val" ].dtype == torch .float32
45
69
]
46
70
47
- # This default compile options are only for mt6989 SOC
48
- compile_options = ["--arch=mdla5.1,edpa1.0" , "--relax-fp32" , "--opt=3" ]
71
+ compile_options = ["--relax-fp32" , "--opt=3" ]
49
72
for spec in module_compile_spec :
50
73
if spec .key in SKIP_COMPILE_SPEC_KEYS :
51
74
continue
0 commit comments