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.

relu_pack4.comp 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 slope = 0;
  16. layout (local_size_x_id = 233) in;
  17. layout (local_size_y_id = 234) in;
  18. layout (local_size_z_id = 235) in;
  19. layout (binding = 0) buffer bottom_top_blob { vec4 bottom_top_blob_data[]; };
  20. layout (push_constant) uniform parameter
  21. {
  22. int dims;
  23. int w;
  24. int h;
  25. int c;
  26. int cstep;
  27. } p;
  28. void main()
  29. {
  30. int gx = int(gl_GlobalInvocationID.x);
  31. int gy = int(gl_GlobalInvocationID.y);
  32. int gz = int(gl_GlobalInvocationID.z);
  33. if (gx >= p.w || gy >= p.h || gz >= p.c)
  34. return;
  35. const int gi = gz * p.cstep + gy * p.w + gx;
  36. vec4 v = bottom_top_blob_data[gi];
  37. if (slope == 0)
  38. v = max(v, 0.0);
  39. else
  40. v = mix(v, v * slope, lessThan(v, vec4(0.0)));
  41. bottom_top_blob_data[gi] = v;
  42. }