Skip to content

Commit ee19963

Browse files
committed
fallback to generic_get_op_desc if no op_desc
1 parent 8bca533 commit ee19963

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

ggml/src/ggml-qnn/op-config-caps.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,29 @@ constexpr const qnn_op_caps_t kOpCaps[] = {
5656
{
5757
// GGML_OP_ADD
5858
QNN_OP_ELEMENT_WISE_ADD, // qnn_op_name
59-
generic_get_op_desc, // get_desc
6059
},
6160
{}, // GGML_OP_ADD1
6261
{}, // GGML_OP_ACC
6362
{
6463
// GGML_OP_SUB
6564
QNN_OP_ELEMENT_WISE_SUBTRACT, // qnn_op_name
66-
generic_get_op_desc, // get_desc
6765
},
6866
{
6967
// GGML_OP_MUL
7068
QNN_OP_ELEMENT_WISE_MULTIPLY, // qnn_op_name
71-
generic_get_op_desc, // get_desc
7269
},
7370
{
7471
// GGML_OP_DIV
7572
QNN_OP_ELEMENT_WISE_DIVIDE, // qnn_op_name
76-
generic_get_op_desc, // get_desc
7773
},
7874
{}, // GGML_OP_SQR
7975
{
8076
// GGML_OP_SQRT
8177
QNN_OP_ELEMENT_WISE_SQUARE_ROOT, // qnn_op_name
82-
generic_get_op_desc, // get_desc
8378
},
8479
{
8580
// GGML_OP_LOG
8681
QNN_OP_ELEMENT_WISE_LOG, // qnn_op_name
87-
generic_get_op_desc, // get_desc
8882
},
8983
{}, // GGML_OP_SIN
9084
{}, // GGML_OP_COS
@@ -108,8 +102,7 @@ constexpr const qnn_op_caps_t kOpCaps[] = {
108102
{}, // GGML_OP_GROUP_NORM
109103
{
110104
// GGML_OP_MUL_MAT
111-
QNN_OP_MAT_MUL, // qnn_op_name
112-
generic_get_op_desc, // get_desc
105+
QNN_OP_MAT_MUL, // qnn_op_name
113106
},
114107
{}, // GGML_OP_MUL_MAT_ID
115108
{}, // GGML_OP_OUT_PROD
@@ -119,8 +112,7 @@ constexpr const qnn_op_caps_t kOpCaps[] = {
119112
{}, // GGML_OP_CONT
120113
{
121114
// GGML_OP_RESHAPE
122-
QNN_OP_RESHAPE, // qnn_op_name
123-
generic_get_op_desc, // get_desc
115+
QNN_OP_RESHAPE, // qnn_op_name
124116
},
125117
{}, // GGML_OP_VIEW
126118
{}, // GGML_OP_PERMUTE
@@ -190,8 +182,7 @@ constexpr const qnn_op_caps_t kOpCaps[] = {
190182
{}, // GGML_UNARY_OP_SIGMOID
191183
{
192184
// GGML_UNARY_OP_GELU
193-
QNN_OP_GELU, // qnn_op_name
194-
generic_get_op_desc, // get_desc
185+
QNN_OP_GELU, // qnn_op_name
195186
},
196187
{}, // GGML_UNARY_OP_GELU_QUICK
197188
{}, // GGML_UNARY_OP_SILU
@@ -201,14 +192,10 @@ constexpr const qnn_op_caps_t kOpCaps[] = {
201192
};
202193

203194
static_assert(kOpCaps[GGML_OP_NONE].get_desc == nullptr, "GGML_OP_NONE should not have get_desc function");
204-
static_assert(kOpCaps[GGML_OP_ADD].get_desc == generic_get_op_desc,
205-
"GGML_OP_ADD does not have element_wise_op_dims function");
206-
static_assert(kOpCaps[GGML_OP_MUL_MAT].get_desc == generic_get_op_desc,
207-
"GGML_OP_MUL_MAT does not have element_wise_op_dims function");
208-
static_assert(kOpCaps[GGML_OP_MUL].get_desc == generic_get_op_desc,
209-
"GGML_OP_MUL does not have element_wise_op_dims function");
210-
static_assert(kOpCaps[GGML_OP_LOG].get_desc == generic_get_op_desc,
211-
"GGML_OP_LOG does not have element_wise_op_dims function");
195+
static_assert(kOpCaps[GGML_OP_ADD].qnn_op_name, "GGML_OP_ADD does not have qnn_op_name in the kOpCaps table");
196+
static_assert(kOpCaps[GGML_OP_MUL_MAT].qnn_op_name, "GGML_OP_MUL_MAT does not have qnn_op_name in the kOpCaps table");
197+
static_assert(kOpCaps[GGML_OP_MUL].qnn_op_name, "GGML_OP_MUL does not have qnn_op_name in the kOpCaps table");
198+
static_assert(kOpCaps[GGML_OP_LOG].qnn_op_name, "GGML_OP_LOG does not have qnn_op_name in the kOpCaps table");
212199
static_assert(std::size(kOpCaps) == (GGML_OP_COUNT + GGML_UNARY_OP_COUNT),
213200
"GGML_OP_COUNT does not match the size of the kOpCaps table");
214201

@@ -424,8 +411,11 @@ void get_qnn_op_desc(const ggml_tensor * op, bool append_dimensions, std::string
424411
auto op_index = get_qnn_op_index(op);
425412
GGML_ASSERT(op_index < std::size(kOpCaps));
426413
auto get_desc = kOpCaps[op_index].get_desc;
427-
GGML_ASSERT(get_desc);
428-
get_desc(op, append_dimensions, output);
414+
if (get_desc) {
415+
get_desc(op, append_dimensions, output);
416+
} else {
417+
generic_get_op_desc(op, append_dimensions, output);
418+
}
429419
}
430420

431421
std::shared_ptr<ggml_qnn_op_config> create_op(const ggml_tensor * op, const std::string & name,

0 commit comments

Comments
 (0)