Skip to content

Commit 9bacd6b

Browse files
noemotiovonnoemotiovonhipudding
authored
[CANN] get_rows and dup optimization (#12671)
* [CANN]get_rows and dup optimization. Co-authored-by: hipudding <[email protected]> Signed-off-by: noemotiovon <[email protected]> * [CANN]GET_ROWS and CPY/DUP optimization Co-authored-by: hipudding <[email protected]> Signed-off-by: noemotiovon <[email protected]> * [CANN]code style adjustment Signed-off-by: noemotiovon <[email protected]> * [CANN]code style adjustment Signed-off-by: noemotiovon <[email protected]> * [CANN]code style adjustment Signed-off-by: noemotiovon <[email protected]> * [CANN]code style adjustment Signed-off-by: noemotiovon <[email protected]> --------- Signed-off-by: noemotiovon <[email protected]> Co-authored-by: noemotiovon <[email protected]> Co-authored-by: hipudding <[email protected]>
1 parent 267c139 commit 9bacd6b

13 files changed

+256
-2033
lines changed

ggml/src/ggml-cann/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ if (CANN_INSTALL_DIR)
5151
${CANN_INSTALL_DIR}/acllib/include
5252
)
5353

54-
add_subdirectory(kernels)
5554
list(APPEND CANN_LIBRARIES
5655
ascendcl
5756
nnopbase
5857
opapi
5958
acl_op_compiler
60-
ascendc_kernels
6159
)
6260

6361
file(GLOB GGML_SOURCES_CANN "*.cpp")

ggml/src/ggml-cann/aclnn_ops.cpp

+241-226
Large diffs are not rendered by default.

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

+15-11
Original file line numberDiff line numberDiff line change
@@ -1704,24 +1704,28 @@ static bool ggml_backend_cann_supports_op(ggml_backend_dev_t dev,
17041704
switch (op->src[0]->type) {
17051705
case GGML_TYPE_F32:
17061706
case GGML_TYPE_F16:
1707-
case GGML_TYPE_Q4_0:
17081707
case GGML_TYPE_Q8_0:
17091708
return true;
17101709
default:
17111710
return false;
17121711
}
17131712
} break;
17141713
case GGML_OP_CPY: {
1715-
switch (op->type) {
1716-
case GGML_TYPE_F32:
1717-
case GGML_TYPE_F16:
1718-
case GGML_TYPE_Q8_0:
1719-
case GGML_TYPE_Q4_0:
1720-
return true;
1721-
default:
1722-
return false;
1714+
ggml_tensor *src = op->src[0];
1715+
if ((op->type != GGML_TYPE_F32 && op->type != GGML_TYPE_F16) ||
1716+
(src->type != GGML_TYPE_F32 &&
1717+
src->type != GGML_TYPE_F16)) {
1718+
// only support F32 and F16.
1719+
return false;
17231720
}
1724-
}
1721+
1722+
if (!ggml_are_same_shape(op, src) && !ggml_is_contiguous(op)) {
1723+
// unsupport dst is not contiguous.
1724+
return false;
1725+
}
1726+
1727+
return true;
1728+
} break;
17251729
case GGML_OP_CONT: {
17261730
// TODO: support GGML_TYPE_BF16
17271731
switch (op->src[0]->type) {
@@ -1762,9 +1766,9 @@ static bool ggml_backend_cann_supports_op(ggml_backend_dev_t dev,
17621766
}
17631767
return true;
17641768
}
1769+
case GGML_OP_DUP:
17651770
case GGML_OP_IM2COL:
17661771
case GGML_OP_CONCAT:
1767-
case GGML_OP_DUP:
17681772
case GGML_OP_REPEAT:
17691773
case GGML_OP_NONE:
17701774
case GGML_OP_RESHAPE:

ggml/src/ggml-cann/kernels/CMakeLists.txt

-30
This file was deleted.

ggml/src/ggml-cann/kernels/ascendc_kernels.h

-19
This file was deleted.

ggml/src/ggml-cann/kernels/dup.cpp

-234
This file was deleted.

0 commit comments

Comments
 (0)