Skip to content

Commit 70e2d1a

Browse files
committed
Update on "[ET-VK] Replace Uniform buffers with push constants for binary op"
This diff replaces uniform buffers with push constants for binary 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: [D66853542](https://our.internmc.facebook.com/intern/diff/D66853542/) [ghstack-poisoned]
2 parents 1b026ff + 9206b9f commit 70e2d1a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
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
/*

0 commit comments

Comments
 (0)