pytorch
57e5ae53 - [vulkan] Use push constants instead of SSBOs (#65716)

Commit
3 years ago
[vulkan] Use push constants instead of SSBOs (#65716) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/65716 Currently, we send arguments to shaders by creating and filling a SSBO (Shader Storage Buffer Object). However, we can instead use [push constants](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushConstants.html) to send a small amount of uniform data to shaders. Push constants are slightly more performant than using a SSBO and also have the added benefit of not needing to allocate and manage memory for a buffer object since they update the pipeline data directly. The downside of using push constants is that there is a maximum size for a push constant block, described by `maxPushConstantsSize` in [VkPhysicalDeviceLimits](https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkPhysicalDeviceLimits). The minimum size guaranteed by the spec is 128 bytes, which is enough for 32 `float`/`int` variables, or 8 `vec4` variables. This should be enough for our purposes. Currently, the Convolution shaders use the largest uniform block which only uses 22 bytes. Test Plan: Run `vulkan_api_test`: ``` buck build -c ndk.custom_libcxx=false -c pt.enable_qpl=0 //xplat/caffe2:pt_vulkan_api_test_binAndroid\#android-arm64 --show-output adb push buck-out/gen/xplat/caffe2/pt_vulkan_api_test_binAndroid\#android-arm64 /data/local/tmp/vulkan_api_test adb shell "/data/local/tmp/vulkan_api_test" ``` Reviewed By: beback4u Differential Revision: D30368834 fbshipit-source-id: 65a42b9da1a9084ba2337b41eaab9b612583c408
Author
Parents
Loading