op_relu.comp 508 B

123456789101112131415161718192021
  1. #version 450
  2. #include "common.comp"
  3. layout(local_size_x = 1) in;
  4. layout(binding = 0) buffer restrict readonly tensorIn { float in_[]; };
  5. layout(binding = 1) buffer restrict writeonly tensorOut { float out_[]; };
  6. layout(push_constant) uniform PushConstants {
  7. uint inOff;
  8. uint outOff;
  9. } pcs;
  10. void main() {
  11. const uint baseIndex = gl_WorkGroupID.x * 4;
  12. for (uint x = 0; x < 4; x++) {
  13. const uint i = baseIndex + x;
  14. out_[i + pcs.outOff] = max(0.0, in_[i + pcs.inOff]);
  15. }
  16. }