@@ -1128,6 +1128,7 @@ static const char * ggmlhexagon_get_socmodel_desc(uint32_t soc_model) {
11281128 }
11291129}
11301130
1131+ // 0x68 -> 68, 0x69 -> 69, 0x73 -> 73, 0x75 -> 75, 0x79 -> 79
11311132static size_t ggmlhexagon_htparch_hex_to_decimal (size_t htp_arch) {
11321133 // naive algorithm
11331134 int a = htp_arch / 16 ;
@@ -1474,6 +1475,27 @@ static void ggmlhexagon_load_cfg() {
14741475 initialized = true ;
14751476}
14761477
1478+ static bool ggmlhexagon_check_valid_appcfg () {
1479+ bool is_valid_appcfg = true ;
1480+
1481+ if (HWACCEL_QNN_SINGLEGRAPH == g_hexagon_appcfg.hwaccel_approach ) {
1482+ GGMLHEXAGON_LOG_INFO (" HWACCEL_QNN_SINGLEGRAPH not supported" );
1483+ is_valid_appcfg = false ;
1484+ }
1485+
1486+ if (HWACCEL_CDSP == g_hexagon_appcfg.hwaccel_approach ) {
1487+ if (HEXAGON_BACKEND_CDSP != g_hexagon_appcfg.hexagon_backend ) {
1488+ GGMLHEXAGON_LOG_INFO (" hwaccel_approach HWACCEL_CDSP must match with hexagon_backend HEXAGON_BACKEND_CDSP" );
1489+ is_valid_appcfg = false ;
1490+ }
1491+ }
1492+
1493+ if (!is_valid_appcfg) {
1494+ GGMLHEXAGON_LOG_INFO (" it seems there is wrong configuration in ggml-hexagon.cfg, will using the default ggml backend accordingly" );
1495+ }
1496+ return is_valid_appcfg;
1497+ }
1498+
14771499// =================================================================================================
14781500// section-5: QNN helper function
14791501// =================================================================================================
@@ -5553,8 +5575,7 @@ static ggml_backend_t ggml_backend_hexagon_device_init_backend(ggml_backend_dev_
55535575 GGMLHEXAGON_LOG_DEBUG (" user's specified hexagon_backend in cfgfile = %d" , g_hexagon_appcfg.hexagon_backend );
55545576 GGMLHEXAGON_LOG_DEBUG (" user's sepcified qnn runtime lib path in cfgfile = %s" , g_hexagon_appcfg.runtimelib_path );
55555577
5556- if (HWACCEL_QNN_SINGLEGRAPH == g_hexagon_appcfg.hwaccel_approach ) {
5557- GGMLHEXAGON_LOG_INFO (" HWACCEL_QNN_SINGLEGRAPH not supported, using default ggml backend" );
5578+ if (!ggmlhexagon_check_valid_appcfg ()) {
55585579 return nullptr ;
55595580 }
55605581
@@ -5740,8 +5761,7 @@ ggml_backend_reg_t ggml_backend_hexagon_reg() {
57405761 return nullptr ;
57415762 }
57425763
5743- if (HWACCEL_QNN_SINGLEGRAPH == g_hexagon_appcfg.hwaccel_approach ) {
5744- GGMLHEXAGON_LOG_INFO (" HWACCEL_QNN_SINGLEGRAPH not supported, using default ggml backend" );
5764+ if (!ggmlhexagon_check_valid_appcfg ()) {
57455765 return nullptr ;
57465766 }
57475767
@@ -5847,8 +5867,7 @@ ggml_backend_t ggml_backend_hexagon_init(size_t device, const char * qnn_lib_pat
58475867 if (nullptr == qnn_lib_path)
58485868 return nullptr ;
58495869
5850- if (HWACCEL_QNN_SINGLEGRAPH == g_hexagon_appcfg.hwaccel_approach ) {
5851- GGMLHEXAGON_LOG_INFO (" HWACCEL_QNN_SINGLEGRAPH not supported, using default ggml backend" );
5870+ if (!ggmlhexagon_check_valid_appcfg ()) {
58525871 return nullptr ;
58535872 }
58545873
0 commit comments