• 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#define PRECISION ${PRECISION}
12
13#define VEC4_T ${texel_type(DTYPE)}
14
15#include "indexing_utils.h"
16
17layout(std430) buffer;
18
19${layout_declare_tensor(0, "w", "image_out", DTYPE, "texture3d")}
20${layout_declare_ubo(1, "ivec4", "sizes")}
21
22layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
23
24layout(constant_id = 3) const int packed_dim = C_DIM;
25layout(constant_id = 4) const int offset = 10;
26
27void main() {
28  const ivec3 pos = ivec3(gl_GlobalInvocationID);
29  const ivec4 idx = to_tensor_idx(pos, sizes, packed_dim);
30
31  if (any(greaterThanEqual(idx, sizes))) {
32    return;
33  }
34
35  const ivec4 buf_indices = get_texel_nchw_buffer_ixs(idx, sizes, packed_dim);
36  VEC4_T texel = VEC4_T(buf_indices) + offset;
37  imageStore(image_out, pos, texel);
38}
39