silu.comp 498 B

12345678910111213141516171819202122
  1. #version 450
  2. #include "generic_head.comp"
  3. #include "types.comp"
  4. #extension GL_EXT_control_flow_attributes : enable
  5. layout(local_size_x = 512, local_size_y = 1, local_size_z = 1) in;
  6. layout (binding = 0) readonly buffer X {A_TYPE data_a[];};
  7. layout (binding = 1) writeonly buffer D {D_TYPE data_d[];};
  8. void main() {
  9. const uint i = gl_GlobalInvocationID.x;
  10. if (i >= p.KX) {
  11. return;
  12. }
  13. const float xi = float(data_a[i]);
  14. data_d[i] = D_TYPE(xi / (1.0f + exp(-xi)));
  15. }