LJTSG commited on
Commit
4976636
·
verified ·
1 Parent(s): 8b153d4

Upload shaders/softplus.wgsl with huggingface_hub

Browse files
Files changed (1) hide show
  1. shaders/softplus.wgsl +14 -0
shaders/softplus.wgsl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // softplus.wgsl — element-wise softplus, in-place.
2
+ // softplus(x) = max(x, 0) + log(1 + exp(-|x|))
3
+
4
+ struct Params { n: u32, }
5
+ @group(0) @binding(0) var<storage, read_write> data: array<f32>;
6
+ @group(1) @binding(0) var<uniform> params: Params;
7
+
8
+ @compute @workgroup_size(64)
9
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
10
+ let i = gid.x;
11
+ if (i >= params.n) { return; }
12
+ let x = data[i];
13
+ data[i] = max(x, 0.0) + log(1.0 + exp(-abs(x)));
14
+ }