Skip to content

Commit ffa449e

Browse files
committed
update some changes
1 parent 88dc242 commit ffa449e

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

ggml/src/ggml-cann/aclnn_ops.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1209,11 +1209,6 @@ void aclnn_sin(ggml_backend_cann_context& ctx, aclTensor* acl_src,
12091209
GGML_CANN_CALL_ACLNN_OP(Sin, acl_src, acl_dst);
12101210
}
12111211

1212-
void aclnn_geluv2(ggml_backend_cann_context& ctx, aclTensor* acl_src,
1213-
aclTensor* acl_dst) {
1214-
GGML_CANN_CALL_ACLNN_OP(GeluV2, acl_src, 0, acl_dst);
1215-
}
1216-
12171212
void ggml_cann_timestep_embedding(ggml_backend_cann_context& ctx,
12181213
ggml_tensor* dst) {
12191214
const ggml_tensor* src = dst->src[0];

ggml/src/ggml-cann/aclnn_ops.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,6 @@ void aclnn_cos(ggml_backend_cann_context& ctx, aclTensor* acl_src,
593593
void aclnn_sin(ggml_backend_cann_context& ctx, aclTensor* acl_src,
594594
aclTensor* acl_dst);
595595

596-
void aclnn_geluv2(ggml_backend_cann_context& ctx, aclTensor* acl_src,
597-
aclTensor* acl_dst);
598-
599596
/**
600597
* @brief Prepares broadcast-compatible ACL tensors for two input tensors and one
601598
* output tensor.
@@ -843,13 +840,14 @@ void ggml_cann_unary_op(
843840
* @see ggml_cann_unary_op
844841
* @see GGML_CANN_CALL_ACLNN_OP
845842
*/
846-
#define GGML_CANN_CALL_UNARY_OP(OP_NAME) \
847-
do { \
848-
ggml_tensor * src = dst->src[0]; \
849-
aclTensor * acl_src = ggml_cann_create_tensor(src); \
850-
aclTensor * acl_dst = ggml_cann_create_tensor(dst); \
851-
GGML_CANN_CALL_ACLNN_OP(OP_NAME, acl_src, acl_dst); \
852-
ACL_CHECK(aclDestroyTensor(acl_src)); \
853-
ACL_CHECK(aclDestroyTensor(acl_dst)); \
854-
} while (0)
843+
#define GGML_CANN_CALL_UNARY_OP(OP_NAME) \
844+
do { \
845+
auto lambda = [](ggml_backend_cann_context& ctx, \
846+
aclTensor* acl_src, \
847+
aclTensor* acl_dst) { \
848+
GGML_CANN_CALL_ACLNN_OP(OP_NAME, acl_src, acl_dst); \
849+
}; \
850+
ggml_cann_unary_op(lambda, ctx, dst); \
851+
} \
852+
while (0)
855853
#endif // CANN_ACLNN_OPS

ggml/src/ggml-cann/ggml-cann.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,12 @@ static bool ggml_cann_compute_forward(ggml_backend_cann_context& ctx,
16021602
GGML_CANN_CALL_UNARY_OP(Silu);
16031603
break;
16041604
case GGML_UNARY_OP_GELU_QUICK: {
1605-
ggml_cann_unary_op<aclnn_geluv2>(ctx, dst);
1605+
auto lambda = [](ggml_backend_cann_context& ctx,
1606+
aclTensor* acl_src,
1607+
aclTensor* acl_dst) {
1608+
GGML_CANN_CALL_ACLNN_OP(GeluV2, acl_src, 0, acl_dst);
1609+
};
1610+
ggml_cann_unary_op(lambda, ctx, dst);
16061611
} break;
16071612
case GGML_UNARY_OP_TANH:
16081613
GGML_CANN_CALL_UNARY_OP(Tanh);

0 commit comments

Comments
 (0)