@mineproness/tensorloop 2.1.74 → 2.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -18,21 +18,21 @@ var<workgroup> partial: array<f32, 64>;
|
|
|
18
18
|
|
|
19
19
|
const D: u32 = %embeddingSize%u;
|
|
20
20
|
const EPSILON: f32 = 1e-6;
|
|
21
|
+
|
|
21
22
|
@compute @workgroup_size(64)
|
|
22
23
|
fn main(@builtin(local_invocation_index) lid: u32, @builtin(workgroup_id) wid: vec3<u32>) {
|
|
23
|
-
let dim = wid.x * 64u +
|
|
24
|
-
if (dim >= D) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
24
|
+
let dim = wid.x * 64u + lid;
|
|
27
25
|
let T = arrayLength(&sumSquares);
|
|
28
|
-
let lr = params[0];
|
|
29
26
|
var sum = 0.0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
if (dim < D) {
|
|
28
|
+
var token = lid;
|
|
29
|
+
|
|
30
|
+
while (token < T) {
|
|
31
|
+
let idx = token * D + dim;
|
|
32
|
+
let r = sqrt(sumSquares[token] / f32(D) + EPSILON);
|
|
33
|
+
sum += gradOutput[idx] * input[idx] / r;
|
|
34
|
+
token += 64u;
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
partial[lid] = sum;
|
|
38
38
|
workgroupBarrier();
|
|
@@ -47,7 +47,8 @@ fn main(@builtin(local_invocation_index) lid: u32, @builtin(workgroup_id) wid: v
|
|
|
47
47
|
workgroupBarrier();
|
|
48
48
|
stride /= 2u;
|
|
49
49
|
}
|
|
50
|
-
if (lid == 0u) {
|
|
51
|
-
|
|
50
|
+
if (lid == 0u && wid.x * 64u < D) {
|
|
51
|
+
let dimToUpdate = wid.x * 64u;
|
|
52
|
+
gamma[dimToUpdate] -= params[0] * partial[0];
|
|
52
53
|
}
|
|
53
54
|
}
|