Skip to content

Commit b4da3b5

Browse files
committed
Update on "[ET-VK] Replace Uniform buffers with push constants for copy op"
This diff replaces uniform buffers with push constants for copy op in the Vulkan backend of Executorch. The changes include updating the GLSL code to use push constants instead of uniform buffers and updating the C++ code to pass the sizes as push constants to the shader. Differential Revision: [D66890851](https://our.internmc.facebook.com/intern/diff/D66890851/) [ghstack-poisoned]
2 parents ee638a9 + 7eb4362 commit b4da3b5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

backends/vulkan/runtime/graph/ops/DispatchNode.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PushConstantDataInfo {
3232
};
3333
struct {
3434
uint8_t data[16];
35-
uint32_t dataSize{};
35+
uint32_t dataSize;
3636
};
3737
};
3838

@@ -46,12 +46,15 @@ class PushConstantDataInfo {
4646
payload_.attr = attr;
4747
}
4848

49-
explicit PushConstantDataInfo(const void* data, uint32_t dataLen)
49+
explicit PushConstantDataInfo(
50+
const void* data,
51+
uint32_t dataLen,
52+
uint32_t pushConstantLen = 0)
5053
: tensorUniformData(nullptr) {
5154
VK_CHECK_COND(
5255
dataLen <= 16, "Single push constant data size must be <= 16 bytes");
53-
payload_.dataSize = dataLen;
54-
memcpy(payload_.data, data, payload_.dataSize);
56+
payload_.dataSize = pushConstantLen ? pushConstantLen : dataLen;
57+
memcpy(payload_.data, data, dataLen);
5558
}
5659

5760
/*

backends/vulkan/runtime/graph/ops/impl/Copy.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ void add_copy_offset_node(
5252
nullptr,
5353
{},
5454
{
55-
PushConstantDataInfo(&range, sizeof(range)),
56-
PushConstantDataInfo(&src_offset, sizeof(src_offset)),
57-
PushConstantDataInfo(&dst_offset, sizeof(dst_offset)),
55+
PushConstantDataInfo(&range, sizeof(range), sizeof(utils::ivec4)),
56+
PushConstantDataInfo(&src_offset, sizeof(src_offset), sizeof(utils::ivec4)),
57+
PushConstantDataInfo(&dst_offset, sizeof(dst_offset), sizeof(utils::ivec4)),
5858
}));
5959
}
6060

0 commit comments

Comments
 (0)