-
Notifications
You must be signed in to change notification settings - Fork 21.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vulkan] Add mean.dim op for vulkan (#47312)
Summary: Pull Request resolved: #47312 Test Plan: ``` cd ~/pytorch BUILD_CUSTOM_PROTOBUF=OFF \ BUILD_TEST=ON \ USE_EIGEN_FOR_BLAS=OFF \ USE_FBGEMM=OFF \ USE_MKLDNN=OFF \ USE_NNPACK=OFF \ USE_NUMPY=OFF \ USE_OBSERVERS=OFF \ USE_PYTORCH_QNNPACK=OFF \ USE_QNNPACK=OFF \ USE_VULKAN=ON \ USE_VULKAN_API=ON \ USE_VULKAN_SHADERC_RUNTIME=ON \ USE_VULKAN_WRAPPER=OFF \ MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python3 setup.py develop --cmake && ./build/bin/vulkan_api_test ``` Reviewed By: IvanKobzarev Differential Revision: D24713617 Pulled By: SS-JIA fbshipit-source-id: 20c0f411fb390ad2114c7deff27cc6fc77448089
- Loading branch information
1 parent
9b168a1
commit 464c569
Showing
4 changed files
with
256 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
layout(std430) buffer; | ||
layout(std430) uniform; | ||
layout(set = 0, binding = 0, rgba16f) uniform PRECISION restrict writeonly image3D uOutput; | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
int W; | ||
int H; | ||
} uBlock; | ||
|
||
layout(local_size_x_id = 1, local_size_y_id = 2, local_size_z_id = 3) in; | ||
|
||
void main() { | ||
ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
vec4 r = vec4(1.0) / (float(uBlock.W) * float(uBlock.H)); | ||
vec4 acc = vec4(0); | ||
int xi, yi; | ||
int zi = (imageSize(uOutput).x*pos.y + pos.x)/4; | ||
int zo = (imageSize(uOutput).x*pos.y + pos.x)%4; | ||
for (yi = 0; yi < uBlock.H; ++yi) { | ||
for (xi = 0; xi < uBlock.W; ++xi) { | ||
acc += texelFetch(uInput, ivec3(xi, yi, zi), 0); | ||
} | ||
} | ||
vec4 outValue = r * acc; | ||
|
||
imageStore(uOutput, pos, vec4(outValue[zo], 0,0,0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.