Skip to content

Add GTests for Conv GPU bias, 1D and 3D paths#31

Open
harz05 wants to merge 1 commit into
ML4EP:gpu/alpakafrom
harz05:feat/conv-dim-coverage-tests
Open

Add GTests for Conv GPU bias, 1D and 3D paths#31
harz05 wants to merge 1 commit into
ML4EP:gpu/alpakafrom
harz05:feat/conv-dim-coverage-tests

Conversation

@harz05

@harz05 harz05 commented Jun 8, 2026

Copy link
Copy Markdown

Adds GTests exercising three Conv GPU paths that no existing alpaka model covered. All current Conv alpaka models are 2D, group 1, no bias, so these branches in the generated kernels were never run.

  • ConvWithBias exercises the BiasBroadcastKernel plus the GEMM beta=1 accumulate. Two output channels with distinct biases (10, 100) so a wrong-channel broadcast is visible.
  • Conv1d exercises the fDim==1 branches in the weight-vec and im2col kernels.
  • Conv3d exercises the fDim>2 depth branches and the depth handling in im2col.

Each model lists W and bias as initializers with an iota input. Reference outputs are verified against PyTorch (F.conv1d / F.conv2d / F.conv3d). Tested on Google Colab (NVIDIA T4, CUDA 12.x): all Conv-dim tests pass with no regressions.

Steps to reproduce on Colab

!apt-get install -y libprotobuf-dev protobuf-compiler libgtest-dev
!git clone https://github.com/harz05/SOFIE.git && cd SOFIE && git checkout feat/conv-dim-coverage-tests
!cd SOFIE && mkdir build && cd build && cmake -Dtesting=ON -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ALPAKA_TESTS=ON -DALPAKA_BACKEND=cuda .. && cmake --build . --target install -j$(nproc)
!cd SOFIE/build && ctest -V

Test models

ConvWithBias : input x[1,1,5,5] = iota, weight W[2,1,3,3] all ones, bias [10, 100], kernel [3,3], pads [1,1,1,1], output y[1,2,5,5]. The two distinct biases make a wrong-channel broadcast visible.

Conv1d : input x[1,2,7] = iota, weight W[3,2,3] = iota, bias [1, 2, 3], kernel [3], pads [1,1], output y[1,3,7].

Conv3d : input x[1,1,3,4,4] = iota, weight W[2,1,2,3,3] = iota, bias [5, 50], kernel [2,3,3], pads [0,1,1,0,1,1] (no depth pad, h/w padded by 1), output y[1,2,2,4,4].

W and bias are ONNX initializers (baked into the .dat), so infer() takes only x. Iota weights give each output and input channel a distinct slice so a wrong index is visible. References computed with PyTorch (cross-correlation, no kernel flip) reading W and bias straight from the committed .onnx.

@harz05 harz05 closed this Jun 8, 2026
@harz05 harz05 reopened this Jun 8, 2026
@harz05 harz05 force-pushed the feat/conv-dim-coverage-tests branch from e68a8ca to 57e467b Compare June 8, 2026 17:53
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