IM2COL support#196
Merged
Merged
Conversation
- 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>
…dices for improved type consistency
…mproved clarity and organization
…iles with per-worker DMA taps
- Format C++ code with clang-format - Format Python code with ruff Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
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_headfor ALiBi slope; scale is vectorized; several kernels standardizeint32_tloop 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. |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.