Skip to content

Commit 09cb721

Browse files
author
noemotiovon
committed
[CANN]Modify the code according to the review comments
Signed-off-by: noemotiovon <[email protected]>
1 parent 153b34d commit 09cb721

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

.devops/llama-cli-cann.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG ASCEND_VERSION=8.0.rc2.alpha003-910b-openeuler22.03-py3.8
1+
ARG ASCEND_VERSION=8.1.RC1.alpha001-910b-openeuler22.03-py3.10
22

33
FROM ascendai/cann:$ASCEND_VERSION AS build
44

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ jobs:
17711771
strategy:
17721772
matrix:
17731773
cann:
1774-
- '8.0.rc3.beta1-910b-openeuler22.03-py3.10'
1774+
- '8.1.RC1.alpha001-910b-openeuler22.03-py3.10'
17751775
device:
17761776
- 'ascend910b3'
17771777
build:

ggml/src/ggml-cann/aclnn_ops.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ void bcast_shape(ggml_tensor * src0, ggml_tensor * src1, ggml_tensor * dst, aclT
8888
}
8989
}
9090

91+
void ggml_cann_unary_op(
92+
std::function<void(ggml_backend_cann_context&, aclTensor*, aclTensor*)> unary_op,
93+
ggml_backend_cann_context& ctx, ggml_tensor* dst) {
94+
ggml_tensor* src = dst->src[0];
95+
96+
aclTensor* acl_src = ggml_cann_create_tensor(src);
97+
aclTensor* acl_dst = ggml_cann_create_tensor(dst);
98+
99+
unary_op(ctx, acl_src, acl_dst);
100+
101+
ACL_CHECK(aclDestroyTensor(acl_src));
102+
ACL_CHECK(aclDestroyTensor(acl_dst));
103+
}
104+
91105
/**
92106
* @brief Repeats elements of a tensor along each dimension according to the
93107
* specified repeat array.

ggml/src/ggml-cann/aclnn_ops.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -756,19 +756,9 @@ template <void unary_op(ggml_backend_cann_context&, aclTensor*, aclTensor*)>
756756
* @param dst The destination tensor where the result will be stored.
757757
* The source tensor is retrieved from `dst->src[0]`.
758758
*/
759-
static void ggml_cann_unary_op_func(
759+
void ggml_cann_unary_op(
760760
std::function<void(ggml_backend_cann_context&, aclTensor*, aclTensor*)> unary_op,
761-
ggml_backend_cann_context& ctx, ggml_tensor* dst) {
762-
ggml_tensor* src = dst->src[0];
763-
764-
aclTensor* acl_src = ggml_cann_create_tensor(src);
765-
aclTensor* acl_dst = ggml_cann_create_tensor(dst);
766-
767-
unary_op(ctx, acl_src, acl_dst);
768-
769-
ACL_CHECK(aclDestroyTensor(acl_src));
770-
ACL_CHECK(aclDestroyTensor(acl_dst));
771-
}
761+
ggml_backend_cann_context& ctx, ggml_tensor* dst);
772762

773763
/**
774764
* @brief Helper macro to invoke a unary ACL operation using ggml_cann_unary_op.
@@ -794,7 +784,7 @@ static void ggml_cann_unary_op_func(
794784
aclTensor* acl_dst) { \
795785
GGML_CANN_CALL_ACLNN_OP(OP_NAME, acl_src, acl_dst); \
796786
}; \
797-
ggml_cann_unary_op_func(lambda, ctx, dst); \
787+
ggml_cann_unary_op(lambda, ctx, dst); \
798788
} \
799789
while (0)
800790
#endif // CANN_ACLNN_OPS

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ static bool ggml_cann_compute_forward(ggml_backend_cann_context& ctx,
13351335
aclTensor* acl_dst) {
13361336
GGML_CANN_CALL_ACLNN_OP(GeluV2, acl_src, 0, acl_dst);
13371337
};
1338-
ggml_cann_unary_op_func(lambda, ctx, dst);
1338+
ggml_cann_unary_op(lambda, ctx, dst);
13391339
} break;
13401340
case GGML_UNARY_OP_TANH:
13411341
GGML_CANN_CALL_UNARY_OP(Tanh);

0 commit comments

Comments
 (0)