Skip to content

flip vulkan shader#6480

Open
futz12 wants to merge 7 commits intoTencent:masterfrom
futz12:flip_vulkan
Open

flip vulkan shader#6480
futz12 wants to merge 7 commits intoTencent:masterfrom
futz12:flip_vulkan

Conversation

@futz12
Copy link
Contributor

@futz12 futz12 commented Jan 2, 2026

No description provided.

@github-actions github-actions bot added the vulkan label Jan 2, 2026
@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 96.85039% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.41%. Comparing base (c374db0) to head (579d003).

Files with missing lines Patch % Lines
src/layer/vulkan/flip_vulkan.cpp 96.85% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6480      +/-   ##
==========================================
- Coverage   93.41%   93.41%   -0.01%     
==========================================
  Files         868      869       +1     
  Lines      275264   274989     -275     
==========================================
- Hits       257146   256868     -278     
- Misses      18118    18121       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tencent-adm
Copy link
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ futz12
❌ nihui
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Vulkan backend support for the Flip layer by introducing dedicated compute shaders and a Vulkan layer implementation, enabling axis-based tensor reversal on GPU for both pack1 and pack4 layouts.

Changes:

  • Added flip.comp (pack1) and flip_pack4.comp (pack4) Vulkan compute shaders implementing flip across up to 4 dimensions.
  • Introduced Flip_vulkan layer with pipeline creation/destruction and VkMat forward path selecting pack1/pack4 pipelines.
  • Wired specialization constants + push constants to match existing Vulkan shader conventions for shape/dispatch parameters.

Reviewed changes

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

File Description
src/layer/vulkan/shader/flip.comp New pack1 Vulkan shader implementing flip coordinate remapping and copy.
src/layer/vulkan/shader/flip_pack4.comp New pack4 Vulkan shader implementing flip plus lane reversal when flipping the packed axis.
src/layer/vulkan/flip_vulkan.h Declares Flip_vulkan layer and pipelines.
src/layer/vulkan/flip_vulkan.cpp Implements pipeline setup and Vulkan forward() dispatch, including axis->flip flag mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
support_vulkan = true;
support_vulkan_packing = true;
support_any_packing = true;
Comment on lines +113 to +129
// compute flip flags exactly like cpu version
int axes_flag[4] = {0};
int flip_w = 0;
int flip_h = 0;
int flip_d = 0;
int flip_c = 0;
{
const int* axes_ptr = axes;
for (int i = 0; i < axes.w; i++)
{
int axis = axes_ptr[i];
if (axis < 0)
axis += dims;

if (axis < 0 || axis >= 4)
continue;

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants