• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9#version 450 core
10
11#include "broadcasting_utils.h"
12#include "indexing_utils.h"
13
14#define PRECISION ${PRECISION}
15
16#define VEC4_T ${texel_load_type(DTYPE, STORAGE)}
17
18layout(std430) buffer;
19
20${layout_declare_tensor(0, "w", "t_out", DTYPE, STORAGE)}
21${layout_declare_tensor(1, "r", "t_in", DTYPE, STORAGE)}
22${layout_declare_ubo(2, "ivec3", "out_limits")}
23${layout_declare_ubo(3, "ivec2", "input_size")}
24${layout_declare_ubo(4, "vec2", "rev_scales")}
25
26layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
27
28void main() {
29  const ivec3 pos = ivec3(gl_GlobalInvocationID);
30
31  if (any(greaterThanEqual(pos, out_limits))) {
32    return;
33  }
34
35  const ivec2 ipos = clamp(ivec2(pos.xy * rev_scales), ivec2(0), input_size);
36
37  VEC4_T in_texel = texelFetch(t_in, ivec3(ipos, pos.z), 0);
38  imageStore(t_out, pos, in_texel);
39}
40