LLM inference in C/C++
C++ ggml
hexagon: enable I32 GET_ROWS (#29116)
Aparna M Pe613ef2c81ba
diff --git a/ggml/src/ggml-hexagon/ggml-hexagon.cpp b/ggml/src/ggml-hexagon/ggml-hexagon.cppindex f84764536b..352434b6a0 100644--- a/ggml/src/ggml-hexagon/ggml-hexagon.cpp+++ b/ggml/src/ggml-hexagon/ggml-hexagon.cpp@@ -5339,11 +5339,12 @@ static bool ggml_hexagon_supported_get_rows(const struct ggml_hexagon_session *}}- if (src0->type != GGML_TYPE_F32 && src0->ne[0] < 32) {+ if (src0->type != GGML_TYPE_F32 && src0->type != GGML_TYPE_I32 && src0->ne[0] < 32) {return false;}- if (src0->type != GGML_TYPE_F32 && src0->type != GGML_TYPE_F16 && src0->type != GGML_TYPE_Q8_0) {+ if (src0->type != GGML_TYPE_F32 && src0->type != GGML_TYPE_F16 &&+ src0->type != GGML_TYPE_Q8_0 && src0->type != GGML_TYPE_I32) {return false;}@@ -5351,7 +5352,12 @@ static bool ggml_hexagon_supported_get_rows(const struct ggml_hexagon_session *return false;}- if (dst->type != GGML_TYPE_F32) {+ if (src0->type == GGML_TYPE_I32) {+ if (dst->type != GGML_TYPE_I32) {+ return false;+ }+ }+ else if (dst->type != GGML_TYPE_F32) {return false;}diff --git a/ggml/src/ggml-hexagon/htp/get-rows-ops.c b/ggml/src/ggml-hexagon/htp/get-rows-ops.cindex d294ba57a0..958ecac3f4 100644--- a/ggml/src/ggml-hexagon/htp/get-rows-ops.c+++ b/ggml/src/ggml-hexagon/htp/get-rows-ops.c@@ -213,11 +213,13 @@ int op_get_rows(struct htp_ops_context * octx) {if (octx->src[0]->type != HTP_TYPE_F32 &&octx->src[0]->type != HTP_TYPE_F16 &&- octx->src[0]->type != HTP_TYPE_Q8_0) {+ octx->src[0]->type != HTP_TYPE_Q8_0 &&+ octx->src[0]->type != HTP_TYPE_I32) {return HTP_STATUS_NO_SUPPORT;}- if (octx->dst->type != HTP_TYPE_F32) {+ if ((octx->src[0]->type == HTP_TYPE_I32 && octx->dst->type != HTP_TYPE_I32) ||+ (octx->src[0]->type != HTP_TYPE_I32 && octx->dst->type != HTP_TYPE_F32)) {return HTP_STATUS_NO_SUPPORT;}@@ -275,6 +277,7 @@ int op_get_rows(struct htp_ops_context * octx) {case HTP_TYPE_F32: q_func = (work_queue_func_t)(is_i32 ? get_rows_thread_f32_int32_t : get_rows_thread_f32_int64_t); break;case HTP_TYPE_F16: q_func = (work_queue_func_t)(is_i32 ? get_rows_thread_f16_int32_t : get_rows_thread_f16_int64_t); break;case HTP_TYPE_Q8_0: q_func = (work_queue_func_t)(is_i32 ? get_rows_thread_q8_0_int32_t : get_rows_thread_q8_0_int64_t); break;+ case HTP_TYPE_I32: q_func = (work_queue_func_t)(is_i32 ? get_rows_thread_st_int32_t : get_rows_thread_st_int64_t); break;default: return HTP_STATUS_NO_SUPPORT;}}diff --git a/ggml/src/ggml-hexagon/htp/htp-tensor.h b/ggml/src/ggml-hexagon/htp/htp-tensor.hindex 3afff69170..1e32bf09f9 100644--- a/ggml/src/ggml-hexagon/htp/htp-tensor.h+++ b/ggml/src/ggml-hexagon/htp/htp-tensor.h@@ -126,6 +126,7 @@ static inline uint32_t htp_tensor_get_row_size(int type, uint32_t ne00) {case HTP_TYPE_F32: return ne00 * 4;case HTP_TYPE_F16: return ne00 * 2;case HTP_TYPE_Q8_0: return (ne00 / 32) * 34;+ case HTP_TYPE_I32: return ne00 * 4;default: return 0;}}