You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

clip.comp 1.5 kB

7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #version 450
  15. layout (constant_id = 0) const float const_min = 0;
  16. layout (constant_id = 1) const float const_max = 0;
  17. layout (local_size_x_id = 233) in;
  18. layout (local_size_y_id = 234) in;
  19. layout (local_size_z_id = 235) in;
  20. layout (binding = 0) buffer bottom_top_blob { float bottom_top_blob_data[]; };
  21. layout (push_constant) uniform parameter
  22. {
  23. int dims;
  24. int w;
  25. int h;
  26. int c;
  27. int cstep;
  28. } p;
  29. void main()
  30. {
  31. int gx = int(gl_GlobalInvocationID.x);
  32. int gy = int(gl_GlobalInvocationID.y);
  33. int gz = int(gl_GlobalInvocationID.z);
  34. if (gx >= p.w || gy >= p.h || gz >= p.c)
  35. return;
  36. const int gi = gz * p.cstep + gy * p.w + gx;
  37. float v = bottom_top_blob_data[gi];
  38. bottom_top_blob_data[gi] = clamp(v, const_min, const_max);
  39. }