Skip to content

Commit 80f3b1b

Browse files
SS-JIAfacebook-github-bot
authored andcommitted
Introduce instrumentation test and custom shader library test for Compute API test (#2259)
Summary: Pull Request resolved: #2259 ## Context Add an Android instrumentation test for `vulkan_compute_api_test` so that changes to the Vulkan Compute API and the Vulkan graph runtime can be tested on Android devices. Also add a test for retrieving a shader from a linked custom shader library. ghstack-source-id: 217501490 bypass-github-pytorch-ci-checks bypass-github-export-checks Reviewed By: jorgep31415 Differential Revision: D54520213 fbshipit-source-id: 111f2c8954c9c5e0107a9f630aac8a23b605692c
1 parent e7197a1 commit 80f3b1b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#version 450 core
2+
#define PRECISION ${PRECISION}
3+
#define FORMAT ${FORMAT}
4+
5+
layout(std430) buffer;
6+
7+
/* Qualifiers: layout - storage - precision - memory */
8+
9+
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput;
10+
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput;
11+
layout(set = 0, binding = 2) uniform PRECISION restrict Block {
12+
ivec4 size;
13+
} uBlock;
14+
15+
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
16+
17+
void main() {
18+
const ivec3 pos = ivec3(gl_GlobalInvocationID);
19+
20+
if (all(lessThan(pos, uBlock.size.xyz))) {
21+
const vec4 intex = texelFetch(uInput, pos, 0);
22+
imageStore(
23+
uOutput,
24+
pos,
25+
intex + 5);
26+
}
27+
}

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class VulkanComputeAPITest : public ::testing::Test {
163163
// Compute API Tests
164164
//
165165

166+
TEST_F(VulkanComputeAPITest, retrieve_custom_shader_test) {
167+
// Try to get shader from custom shader library
168+
const api::ShaderInfo& kernel = VK_KERNEL(test_shader);
169+
170+
EXPECT_TRUE(kernel.kernel_name == "test_shader");
171+
}
172+
166173
TEST_F(VulkanComputeAPITest, buffer_copy_sanity_check) {
167174
// Simple test that copies data into a and reads from a
168175
std::vector<int64_t> sizes = {4, 4, 1};

0 commit comments

Comments
 (0)