Skip to content

Commit f535a04

Browse files
copyrightlyfacebook-github-bot
authored andcommitted
Generate int variants for binary_ops (#2472)
Summary: Add int variant for binary_ops shader. Reviewed By: SS-JIA, jorgep31415 Differential Revision: D54963877
1 parent e3ee6d9 commit f535a04

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ void main() {
5252
}
5353

5454
ivec4 in_coord = out_coord_to_in_coord(coord, in_sizes.data);
55-
vec4 in_texel = texelFetch(
55+
${VEC4_T[DTYPE]} in_texel = ${VEC4_T[DTYPE]}(texelFetch(
5656
image_in,
5757
COORD_TO_POS_${PACKING}(in_coord, in_sizes.data),
58-
0);
58+
0));
5959

6060
ivec4 other_coord = out_coord_to_in_coord(coord, other_sizes.data);
61-
vec4 other_texel = texelFetch(
61+
${VEC4_T[DTYPE]} other_texel = ${VEC4_T[DTYPE]}(texelFetch(
6262
image_other,
6363
COORD_TO_POS_${PACKING}(other_coord, other_sizes.data),
64-
0);
64+
0));
6565

6666
// Detect broadcasting
6767
if (PACKED_DIM_${PACKING}(other_sizes.data) < PACKED_DIM_${PACKING}(in_sizes.data)) {
6868
other_texel = other_texel.xxxx;
6969
}
7070

71-
imageStore(image_out, pos, OP(in_texel, other_texel, alpha.data));
71+
imageStore(image_out, pos, ${VEC4_T[DTYPE]}(OP(in_texel, other_texel, alpha.data)));
7272
}

backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ binary_op:
2323
SUFFIX: half
2424
- VALUE: float
2525
SUFFIX: float
26+
- VALUE: int
27+
SUFFIX: int
2628
shader_variants:
2729
- NAME: binary_add
2830
- NAME: binary_sub

0 commit comments

Comments
 (0)