Skip to content

IM2COL support#196

Merged
ypapadop-amd merged 11 commits into
hsa-backendfrom
ypapadop-amd/im2col
Jul 10, 2026
Merged

IM2COL support#196
ypapadop-amd merged 11 commits into
hsa-backendfrom
ypapadop-amd/im2col

Conversation

@ypapadop-amd

@ypapadop-amd ypapadop-amd commented Jul 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

ypapadop-amd and others added 8 commits July 8, 2026 01:01
- Added "aie_kernel_utils.h" include to aie_kernel_math.h for utility functions.
- Updated ggml_op_clamp and ggml_op_scale to include event tracking.
- Refactored ggml_op_pool_2d for improved readability and performance.
- Modified softmax operations to incorporate ALiBi slope adjustments.
- Added n_head parameter to softmax functions for better attention handling.
Co-Authored-By: Claude <noreply@anthropic.com>
ypapadop-amd and others added 2 commits July 10, 2026 13:08
- Format C++ code with clang-format
- Format Python code with ruff

Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GGML_OP_IM2COL support to the ggml-hsa backend (IRON/AIE path) so 2D convolution graphs that lower via im2col can run on AMD XDNA devices, and wires the new op through the kernel build/dispatch pipeline.

Changes:

  • Implement IM2COL IRON kernel (Python IRON program + AIE core C++), register it in kernel build/dispatch, and document support.
  • Add HSA MNIST backend tests covering im2col shapes used by the MNIST-CNN layers.
  • Misc. kernel improvements/maintenance: softmax sink variant adds n_head for ALiBi slope; scale is vectorized; several kernels standardize int32_t loop counters/includes.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/ggml-hsa/test-backend-ops-mnist.cpp Adds an IM2COL test case and instantiates MNIST-CNN im2col scenarios.
src/ggml-hsa/README.md Documents IM2COL as a supported convolution-related op for ggml-hsa.
src/ggml-hsa/kernels/iron_kernels/im2col.py New IRON program builder for IM2COL (batch-parallel workers, DMA taps, external function wiring).
src/ggml-hsa/kernels/iron_kernels/im2col.cc New AIE core function implementing one output-row of 2D im2col.
src/ggml-hsa/kernels/im2col.py Adds the top-level kernel dispatch entry point for IM2COL.
src/ggml-hsa/kernels/build.py Registers IM2COL op mapping; switches backend compiler resolution to lazy imports.
src/ggml-hsa/kernels/CMakeLists.txt Ensures IM2COL python dispatch module is installed/built when JIT compiling.
src/ggml-hsa/kernels/iron_kernels/CMakeLists.txt Adds IM2COL sources to IRON kernel file list.
src/ggml-hsa/kernels/build_iron.py Moves IRON-related imports to module scope (cleanup).
src/ggml-hsa/kernels/build_triton.py Adjusts Triton import location (paired with lazy import in build.py).
src/ggml-hsa/kernels/iron_kernels/softmax.py Passes n_head into sink+mask softmax external call; updates arg typing.
src/ggml-hsa/kernels/iron_kernels/softmax.cc Updates sink+mask softmax signature and applies ALiBi slope to mask term.
src/ggml-hsa/kernels/iron_kernels/scale.cc Vectorizes scale+bias with AIE vector ops and adds profiling events.
src/ggml-hsa/kernels/iron_kernels/pool_2d.cc Refactors pooling loops for clearer max vs avg paths.
src/ggml-hsa/kernels/iron_kernels/clamp.cc Adds restrict qualifiers and event profiling calls.
src/ggml-hsa/kernels/iron_kernels/count_equal.cc Uses mask.count() on non-aie2, retains per-bit counting for aie2.
src/ggml-hsa/kernels/iron_kernels/aie_kernel_math.h Adds utils include; switches unroll pragma to project macro; uses int32_t temporaries.
src/ggml-hsa/kernels/iron_kernels/ggml-aie.hpp Fixes an example comment for clarity.
src/ggml-hsa/kernels/iron_kernels/aie2/mm.cc Standardizes integer types/includes in templates and loops.
src/ggml-hsa/kernels/iron_kernels/aie2/zero.cc Standardizes integer types/includes in templates and loops.
src/ggml-hsa/kernels/iron_kernels/aie2p/mm.cc Standardizes integer types/includes in templates and loops.
src/ggml-hsa/kernels/iron_kernels/aie2p/zero.cc Standardizes integer types in templates and loops.
src/ggml-hsa/AGENTS.md Updates documentation to match new lazy compiler resolution pattern in build.py.

Comment thread src/ggml-hsa/kernels/iron_kernels/im2col.py
Comment thread src/ggml-hsa/kernels/iron_kernels/im2col.cc
Copilot AI review requested due to automatic review settings July 10, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Comment thread src/ggml-hsa/kernels/iron_kernels/scale.cc
Copilot AI review requested due to automatic review settings July 10, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.

@ypapadop-amd ypapadop-amd merged commit b6a3837 into hsa-backend Jul 10, 2026
2 checks passed
@ypapadop-amd ypapadop-amd deleted the ypapadop-amd/im2col branch July 10, 2026 17:37
ypapadop-amd added a commit that referenced this pull request Jul 12, 2026
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

2 participants