Skip to content

Commit e5429a9

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 Differential Revision: D54963877
1 parent 5f225aa commit e5429a9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ binary_op:
1919
- VALUE: HEIGHT_PACKED
2020
SUFFIX: H_packed
2121
DTYPE:
22-
- VALUE: half
23-
SUFFIX: half
24-
- VALUE: float
25-
SUFFIX: float
22+
- VALUE: "half"
23+
SUFFIX: "half"
24+
- VALUE: "float"
25+
SUFFIX: "float"
26+
- VALUE: "int"
27+
SUFFIX: "int"
2628
shader_variants:
2729
- NAME: binary_add
2830
- NAME: binary_sub

0 commit comments

Comments
 (0)