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.

absval.comp 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #if NCNN_fp16_storage
  16. #extension GL_AMD_gpu_shader_half_float: require
  17. #define sfp float16_t
  18. #define sfpvec4 f16vec4
  19. #define sfpmat4 f16mat4
  20. #else
  21. #define sfp float
  22. #define sfpvec4 vec4
  23. #define sfpmat4 mat4
  24. #endif
  25. #if NCNN_fp16_arithmetic
  26. #extension GL_AMD_gpu_shader_half_float: require
  27. #define afp float16_t
  28. #define afpvec4 f16vec4
  29. #define afpmat4 f16mat4
  30. #else
  31. #define afp float
  32. #define afpvec4 vec4
  33. #define afpmat4 mat4
  34. #endif
  35. layout (local_size_x_id = 233) in;
  36. layout (local_size_y_id = 234) in;
  37. layout (local_size_z_id = 235) in;
  38. layout (binding = 0) buffer bottom_top_blob { sfp bottom_top_blob_data[]; };
  39. layout (push_constant) uniform parameter
  40. {
  41. int dims;
  42. int w;
  43. int h;
  44. int c;
  45. int cstep;
  46. } p;
  47. void main()
  48. {
  49. int gx = int(gl_GlobalInvocationID.x);
  50. int gy = int(gl_GlobalInvocationID.y);
  51. int gz = int(gl_GlobalInvocationID.z);
  52. if (gx >= p.w || gy >= p.h || gz >= p.c)
  53. return;
  54. const int gi = gz * p.cstep + gy * p.w + gx;
  55. afp v = bottom_top_blob_data[gi];
  56. bottom_top_blob_data[gi] = sfp(abs(v));
  57. }