Skip to content

Commit c50f9fe

Browse files
nathanaelseefacebook-github-bot
authored andcommitted
update copy_offset to new layout specifier gen & axis mapping (#5505)
Summary: Pull Request resolved: #5505 Reviewed By: SS-JIA Differential Revision: D63000056 fbshipit-source-id: 959127e874b30c7ebc069499d99e8c5881b3b272
1 parent 613cfd6 commit c50f9fe

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

backends/vulkan/runtime/graph/ops/glsl/copy_offset.glsl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@
1010

1111
#define PRECISION ${PRECISION}
1212

13+
#include "indexing_utils.h"
14+
1315
layout(std430) buffer;
1416

15-
${layout_declare_tensor(0, "w", "t_out", DTYPE, STORAGE)}
16-
${layout_declare_tensor(1, "r", "t_in", DTYPE, STORAGE)}
17+
${layout_declare_tensor(B, "w", "t_out", DTYPE, STORAGE)}
18+
${layout_declare_tensor(B, "r", "t_in", DTYPE, STORAGE)}
1719

18-
layout(set = 0, binding = 2) uniform PRECISION restrict CopyArgs {
19-
ivec3 range;
20-
int unused0;
21-
ivec3 src_offset;
22-
int unused1;
23-
ivec3 dst_offset;
24-
int unused2;
25-
};
20+
${layout_declare_ubo(B, "ivec3", "range", "ivec3", "src_offset", "ivec3", "dst_offset")}
21+
${layout_declare_ubo(B, "ivec4", "out_axis_map")}
22+
${layout_declare_ubo(B, "ivec4", "in_axis_map")}
2623

2724
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
2825

@@ -36,5 +33,9 @@ void main() {
3633
return;
3734
}
3835

39-
imageStore(t_out, out_pos, texelFetch(t_in, in_pos, 0));
36+
write_texel_lpos(
37+
t_out,
38+
out_pos,
39+
load_texel_lpos(t_in, in_pos, in_axis_map),
40+
out_axis_map);
4041
}

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,13 @@ void add_copy_offset_node(
3333
add_dtype_suffix(kernel_name, *t_out);
3434

3535
const struct Block final {
36-
ivec3 range;
37-
int32_t unused0;
38-
ivec3 src_offset;
39-
int32_t unused1;
40-
ivec3 dst_offset;
41-
int32_t unused2;
36+
alignas(16) ivec3 range;
37+
alignas(16) ivec3 src_offset;
38+
alignas(16) ivec3 dst_offset;
4239
} offset_params{
4340
range,
44-
0,
4541
src_offset,
46-
0,
4742
dst_offset,
48-
0,
4943
};
5044

5145
auto shader = VK_KERNEL_FROM_STR(kernel_name);
@@ -61,7 +55,11 @@ void add_copy_offset_node(
6155
{in, vkapi::MemoryAccessType::READ},
6256
},
6357
// Parameter buffers
64-
{graph.create_params_buffer(offset_params)},
58+
{
59+
graph.create_params_buffer(offset_params),
60+
t_out->axis_map_ubo(),
61+
t_in->axis_map_ubo(),
62+
},
6563
// Specialization Constants
6664
{}));
6765
}

0 commit comments

Comments
 (0)