@@ -1025,13 +1025,26 @@ static bool parse_engine(
1025
1025
" `cpu` or `gpu`.\n `INDEX` is an integer value specifying "
1026
1026
" which engine to use if several were identified.\n " ;
1027
1027
1028
+ // Note: this is a special case because index and engine kind are parsed
1029
+ // into separate global objects instead of one under a common parsing
1030
+ // function.
1031
+ // TODO: fix this.
1032
+ //
1033
+ // Because of this fact, need to extract kind separated by `:`. `:` can be
1034
+ // valid dangling for certain options in the command line (--strides=::).
1035
+ // Thus, extract the kind allowing dangling. Verify, it's `--engine` option,
1036
+ // and if yes, perform a safe check for dangling after.
1028
1037
size_t start_pos = 0 ;
1029
- std::string kind_str = get_substr (str, start_pos, ' :' );
1038
+ std::string kind_str = get_substr (str, start_pos, ' :' , true );
1030
1039
1031
1040
if (!parse_single_value_option (engine_tgt_kind, dnnl_cpu, str2engine_kind,
1032
1041
kind_str.c_str (), option_name, help))
1033
1042
return false ;
1034
1043
1044
+ // This is to catch a dangling `:` at the end of `--engine`.
1045
+ start_pos = 0 ;
1046
+ kind_str = get_substr (str, start_pos, ' :' );
1047
+
1035
1048
if (start_pos != std::string::npos) {
1036
1049
std::string index_str (str + start_pos);
1037
1050
// If the index is a valid number, let the library catch potential
0 commit comments