ggml-hexagon: gelu operation (#17921)
* feat: inital support for gelu using sigmoid approximation * snapshot: faster gelu using polynomial approximation * test: disable l2-block prefetch in polynomail approximation * Revert "test: disable l2-block prefetch in polynomail approximation" This reverts commit 72339994d45b2bed887e79994403c378d90b62b5. * Revert "snapshot: faster gelu using polynomial approximation" This reverts commit 2a787a61d11f9e63e5943a2e6d134b2f0c402ace. * debug: temporarily disable unnecessary log message for debug purpose * Feat: optiized unaligned sigmoid_f32 * Feat: larger l2prefetch block * feat: apply unaligned-load optimization on mul and mul_scalar * Revert "debug: temporarily disable unnecessary log message for debug purpose" This reverts commit 84f2f23aa9f17e2fa826db969cd825d0ab192995. * refactor: cleanup commented unused code * chore: reformat code with clang-formatter to pass cli test * Revert "chore: reformat code with clang-formatter to pass cli test" This reverts commit 952877ec24732b12010c7fa7ed3fc8de4b74e718. * fix: fix loop overflow * chore: fix formating ci error
This commit is contained in:
@@ -2161,8 +2161,14 @@ static bool ggml_hexagon_supported_activations(const struct ggml_hexagon_session
|
||||
}
|
||||
|
||||
// src0, src1 & dst must be mapped to the same session
|
||||
if (!hex_supported_buffer(sess, src0, src1, dst)) {
|
||||
return false;
|
||||
if(src1){
|
||||
if (!hex_supported_buffer(sess, src0, src1, dst)) {
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
if (!hex_supported_buffer(sess, src0, dst)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2662,6 +2668,10 @@ static void ggml_hexagon_unary(const struct ggml_tensor * op, uint32_t flags) {
|
||||
req.op = HTP_OP_UNARY_SILU;
|
||||
supported = true;
|
||||
}
|
||||
else if (ggml_get_unary_op(dst) == GGML_UNARY_OP_GELU){
|
||||
req.op = HTP_OP_UNARY_GELU;
|
||||
supported = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case GGML_OP_GLU:
|
||||
@@ -2677,6 +2687,7 @@ static void ggml_hexagon_unary(const struct ggml_tensor * op, uint32_t flags) {
|
||||
case GGML_OP_SOFT_MAX:
|
||||
req.op = HTP_OP_SOFTMAX;
|
||||
supported = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -2956,6 +2967,8 @@ static ggml_status ggml_backend_hexagon_graph_compute(ggml_backend_t backend, gg
|
||||
case GGML_OP_UNARY:
|
||||
if (ggml_get_unary_op(node) == GGML_UNARY_OP_SILU) {
|
||||
ggml_hexagon_unary(node, flags);
|
||||
} else if (ggml_get_unary_op(node) == GGML_UNARY_OP_GELU) {
|
||||
ggml_hexagon_unary(node, flags);
|
||||
}
|
||||
break;
|
||||
case GGML_OP_GLU:
|
||||
@@ -3254,7 +3267,6 @@ static bool ggml_backend_hexagon_device_supports_op(ggml_backend_dev_t dev, cons
|
||||
auto sess = static_cast<ggml_hexagon_session *>(dev->context);
|
||||
|
||||
bool supp = false;
|
||||
|
||||
switch (op->op) {
|
||||
case GGML_OP_NONE:
|
||||
case GGML_OP_RESHAPE:
|
||||
@@ -3294,6 +3306,9 @@ static bool ggml_backend_hexagon_device_supports_op(ggml_backend_dev_t dev, cons
|
||||
if (ggml_get_unary_op(op) == GGML_UNARY_OP_SILU) {
|
||||
supp = ggml_hexagon_supported_activations(sess, op);
|
||||
}
|
||||
else if (ggml_get_unary_op(op) == GGML_UNARY_OP_GELU){
|
||||
supp = ggml_hexagon_supported_activations(sess, op);
|
||||
}
|
||||
break;
|
||||
|
||||
case GGML_OP_GLU:
|
||||
|
||||
Reference in New Issue
Block a user