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
def assert_default_dim_order (edge_graph_module : torch .fx .GraphModule ) -> None :
@@ -47,6 +49,28 @@ def preprocess(
47
49
cls , edge_program : ExportedProgram , module_compile_spec : List [CompileSpec ]
48
50
) -> PreprocessResult :
49
51
52
+ # Validate CompileSpec settings
53
+ compile_spec_keys = [spec .key for spec in module_compile_spec ]
54
+ if len (compile_spec_keys ) != len (set (compile_spec_keys )):
55
+ raise RuntimeError (
56
+ "Unsupported duplicated keys in the CompileSpec settings."
57
+ )
58
+ if not REQUIRED_COMPILE_SPEC_KEYS .issubset (set (compile_spec_keys )):
59
+ raise RuntimeError (
60
+ "Following keys are required in the CompileSpec settings: {}."
61
+ "" .format (REQUIRED_COMPILE_SPEC_KEYS )
62
+ )
63
+ platform = [
64
+ spec .value .decode ("utf-8" )
65
+ for spec in module_compile_spec
66
+ if spec .key == "platform-config"
67
+ ][0 ]
68
+ if platform not in SUPPORTED_PLATFORM_CONFIGS :
69
+ raise ValueError (
70
+ "Unsupported value of platform-config CompileSpec. Given {} but expected to be one "
71
+ "of {}." .format (platform , SUPPORTED_PLATFORM_CONFIGS )
72
+ )
73
+
50
74
# Make sure all inputs are contiguous_format or NCHW or default dim order
51
75
assert_default_dim_order (edge_program .graph_module )
52
76
@@ -64,8 +88,7 @@ def preprocess(
64
88
if name_to_node_mappings [name ].meta ["val" ].dtype == torch .float32
65
89
]
66
90
67
- # This default compile options are only for mt6989 SOC
68
- compile_options = ["--arch=mdla5.1,edpa1.0" , "--relax-fp32" , "--opt=3" ]
91
+ compile_options = ["--relax-fp32" , "--opt=3" ]
69
92
for spec in module_compile_spec :
70
93
if spec .key in SKIP_COMPILE_SPEC_KEYS :
71
94
continue
0 commit comments