18 lines
592 B
Plaintext
18 lines
592 B
Plaintext
#version 450
|
|
/* LeakyReLU: out = (x >= 0) ? x : slope * x. In-place safe (binding 0 and 1
|
|
* may alias). Used by the RealESRGAN (RRDBNet) upscaler. */
|
|
layout(local_size_x = 256) in;
|
|
|
|
layout(std430, binding = 0) readonly buffer In { float x[]; };
|
|
layout(std430, binding = 1) writeonly buffer Out { float outp[]; };
|
|
|
|
layout(push_constant) uniform PC { uint n; float slope; } pc;
|
|
|
|
void main() {
|
|
uint stride_g = gl_NumWorkGroups.x * 256u;
|
|
for (uint i = gl_GlobalInvocationID.x; i < pc.n; i += stride_g) {
|
|
float v = x[i];
|
|
outp[i] = (v >= 0.0) ? v : v * pc.slope;
|
|
}
|
|
}
|