Skip to content

feat(cambricon): add convolution provider - #967

Draft
baominghelly wants to merge 1 commit into
masterfrom
feat/cambricon-convolution
Draft

feat(cambricon): add convolution provider#967
baominghelly wants to merge 1 commit into
masterfrom
feat/cambricon-convolution

Conversation

@baominghelly

Copy link
Copy Markdown
Contributor

Summary

  • Add a CNNL-backed Cambricon provider in src/native/cambricon/ops/convolution/cnnl.h.
  • Support contiguous forward convolution for 1D, 2D, and 3D inputs, with or without bias, by converting input and weight layouts for CNNL and copying the CNNL output buffer directly to the operator output.

Motivation

InfiniOps already exposes the convolution operator, but the native Cambricon backend had no provider. This change enables convolution workloads to dispatch on Cambricon devices.

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

The repository-wide Cambricon smoke build and smoke test set were not run. A fresh operator-targeted Cambricon build with generated Python bindings and the complete convolution test file passed:

export INFINI_OPS_DISPATCH_BATCH_SIZE=64
cmake -S . -B /workspace/build/publish-convolution \
  -DAUTO_DETECT_DEVICES=OFF \
  -DWITH_CPU=ON \
  -DWITH_CAMBRICON=ON \
  -DWITH_TORCH=OFF \
  -DWITH_LINKED=OFF \
  -DGENERATE_PYTHON_BINDINGS=ON \
  -DINFINI_OPS_OPS=convolution \
  -DINFINI_RT_ROOT=/workspace/install/infinirt-master-test \
  -DPython_EXECUTABLE=/torch/venv3/pytorch/bin/python3.10 \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/workspace/build/publish-convolution-site/infini
cmake --build /workspace/build/publish-convolution --parallel "$(nproc)"
cmake --install /workspace/build/publish-convolution
PYTHONPATH=/workspace/build/publish-convolution-site \
LD_LIBRARY_PATH=/workspace/build/publish-convolution-site/infini:/workspace/install/infinirt-master-test/lib \
  /torch/venv3/pytorch/bin/python3.10 -m pytest -q \
  tests/test_convolution.py --devices cambricon --maxfail=1

......                                                                   [100%]
6 passed in 0.13s

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA No N/A - not affected N/A - not affected
Iluvatar No N/A - not affected N/A - not affected
MetaX No N/A - not affected N/A - not affected
Cambricon Yes Targeted build passed; repository smoke not run tests/test_convolution.py: 6 passed in 0.13s
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected
Full `pytest` output (optional)
......                                                                   [100%]
6 passed in 0.13s

Benchmark / Performance Impact

N/A — no performance benchmark was run.

Notes for Reviewers

  • The provider currently handles forward convolution only; transposed convolution is outside this change.
  • Inputs, weights, outputs, and optional bias must be contiguous.
  • The tests cover 1D, 2D, and 3D convolution, each with and without bias.
  • The current test matrix validates the default FP32 path. FP16 and BF16 were not separately validated.
  • With the CNNL output descriptor used here, the output buffer already has the linear order expected by InfiniOps. Applying an additional NHWC/NDHWC-to-channel-first transpose produces incorrectly permuted values, so the provider performs a device-to-device copy instead.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant