Skip to content

Conversation

@Intellouis
Copy link

@Intellouis Intellouis commented Dec 11, 2025

Description

This PR implements support for kernel_size > 255 in the CANN backend for the ggml's CONV_TRANSPOSE_1D operator. The existing CONV_TRANSPOSE_1D operator, implemented via a direct call to Convolution, throws a shape error for inputs whose kernel_size is greater than 255.

Summary of changes:

  1. Added the header file aclnnop/aclnn_slice.h to ggml/src/ggml-cann/aclnn_ops.h to support slice operations.

  2. Added function implementation in ggml/src/ggml-cann/aclnn_ops.cpp. The general approach is as follows:

  • Slice the large kernel into multiple smaller kernels each ≤ 255.
  • Perform CONV_TRANSPOSE_1D on each small kernel with the input to obtain partial results.
  • Calculate the start and end positions of each partial result within the final output and pad them to the same length as the output.
  • Sum all partial results to get the final output.
  1. In ggml/src/ggml-cann/ggml-cann.cpp, remove the condition check:
case GGML_OP_CONV_TRANSPOSE_1D:
    // TODO: ((weightL - 1) * dilationW - padLeft)=1336 should not be larger than 255.
    return (op->src[0]->ne[0] - 1) <= 255;

Testing

Test steps:

  • Building:
cmake -B build -DGGML_CANN=on -DCMAKE_BUILD_TYPE=release
cmake --build build --config release -j
  • Run test:
./bin/test-backend-ops test -b CANN0 -o CONV_TRANSPOSE_1D

All test cases should be passed.

@github-actions github-actions bot added ggml changes relating to the ggml tensor library for machine learning Ascend NPU issues specific to Ascend NPUs labels Dec 11, 2025
@ixgbe
Copy link
Contributor

ixgbe commented Dec 12, 2025

Could you please update the PR description in English?
This helps the maintainers and reviewers understand the changes more easily and keeps the project documentation consistent.

@Intellouis Intellouis changed the title CANN: CONV_TRANSPOSE_1D算子:支持 (op->src[0]->ne[0] - 1) > 255 场景 CANN: CONV_TRANSPOSE_1D operator: supporting the cases where (op->src[0]->ne[0] - 1) > 255 Dec 12, 2025
@Intellouis
Copy link
Author

Could you please update the PR description in English? This helps the maintainers and reviewers understand the changes more easily and keeps the project documentation consistent.

Sure! I have edited the PR in English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ascend NPU issues specific to Ascend NPUs ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants