@imaduddin/fastbrain 2.0.2 → 2.0.4
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/dist/Embedding/index.js +1 -1
- package/dist/Gelu/index.js +1 -1
- package/dist/Linear/index.js +1 -1
- package/dist/RMSNorm/index.js +1 -1
- package/dist/SelfAttention/index.js +1 -1
- package/dist/Softmax/index.js +1 -1
- package/dist/residualConnection/index.js +3 -1
- package/package.json +1 -1
- package/src/Embedding/index.ts +1 -1
- package/src/Gelu/index.ts +1 -1
- package/src/Linear/index.ts +1 -1
- package/src/RMSNorm/index.ts +1 -1
- package/src/SelfAttention/index.ts +1 -1
- package/src/Softmax/index.ts +1 -1
- package/src/residualConnection/index.ts +2 -1
package/dist/Embedding/index.js
CHANGED
package/dist/Gelu/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export class Gelu {
|
|
|
16
16
|
this.device = device;
|
|
17
17
|
this.hiddenSize = hiddenSize;
|
|
18
18
|
this.gpu = new GPUManager(device, {
|
|
19
|
-
shaderDir: join(__dirname, "
|
|
19
|
+
shaderDir: join(__dirname, "../../shaders/relu")
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
async forward(input, encoderShared) {
|
package/dist/Linear/index.js
CHANGED
package/dist/RMSNorm/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export class RMSNorm {
|
|
|
17
17
|
this.device = device;
|
|
18
18
|
this.embeddingSize = embeddingSize;
|
|
19
19
|
this.gpu = new GPUManager(device, {
|
|
20
|
-
shaderDir: join(__dirname, "
|
|
20
|
+
shaderDir: join(__dirname, "../../shaders/rmsnorm")
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
async forward(input, encoderShared) {
|
|
@@ -49,7 +49,7 @@ export class SelfAttention {
|
|
|
49
49
|
filename: [join(configs.dirname, "LINEAR_KEY_WEIGHTS.bin"), join(configs.dirname, "LINEAR_KEY_BIAS.bin")]
|
|
50
50
|
});
|
|
51
51
|
this.gpu = new GPUManager(device, {
|
|
52
|
-
shaderDir: join(__dirname, "shaders/")
|
|
52
|
+
shaderDir: join(__dirname, "../../shaders/")
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
async softmaxBackward(weights, dWeigths, output, tokenCount, enocder) {
|
package/dist/Softmax/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export class Softmax {
|
|
|
19
19
|
this.device = device;
|
|
20
20
|
this.VocabSize = VocabSize;
|
|
21
21
|
this.gpu = new GPUManager(device, {
|
|
22
|
-
shaderDir: join(__dirname, '
|
|
22
|
+
shaderDir: join(__dirname, '../../shaders/softmax')
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
async forward(logit, encoderShared) {
|
|
@@ -10,7 +10,7 @@ export class residualConnection {
|
|
|
10
10
|
constructor(device) {
|
|
11
11
|
this.device = device;
|
|
12
12
|
this.gpu = new GPUManager(device, {
|
|
13
|
-
shaderDir: join(__dirname, "
|
|
13
|
+
shaderDir: join(__dirname, "../../shaders")
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
async add(a, b) {
|
|
@@ -20,6 +20,8 @@ export class residualConnection {
|
|
|
20
20
|
this.output.destroy();
|
|
21
21
|
this.output = await this.gpu?.createBuffer(new Float32Array(a.buffer.size / 4), "storage");
|
|
22
22
|
}
|
|
23
|
+
if (!this.addShader)
|
|
24
|
+
this.addShader = await this.gpu?.getPiplineShader("add.wgsl");
|
|
23
25
|
const bindGroup = await this.gpu?.createBindGroup(this.addShader, [a, b, this.output], 0);
|
|
24
26
|
await this.gpu?.RunPipline(encoder, this.addShader, bindGroup, Math.ceil((a.buffer.size / 4) / 64));
|
|
25
27
|
await this.gpu?.SumbitEncoder(encoder);
|
package/package.json
CHANGED
package/src/Embedding/index.ts
CHANGED
package/src/Gelu/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class Gelu {
|
|
|
15
15
|
gpu: GPUManager | undefined;
|
|
16
16
|
constructor(public device: GPUDevice, public hiddenSize: number) {
|
|
17
17
|
this.gpu = new GPUManager(device, {
|
|
18
|
-
shaderDir: join(__dirname,"
|
|
18
|
+
shaderDir: join(__dirname,"../../shaders/relu")
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
async forward(input: Buffer, encoderShared: GPUCommandEncoder | undefined) {
|
package/src/Linear/index.ts
CHANGED
package/src/RMSNorm/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export class RMSNorm {
|
|
|
16
16
|
gpu: GPUManager | undefined
|
|
17
17
|
constructor(public device: GPUDevice, public embeddingSize: number) {
|
|
18
18
|
this.gpu = new GPUManager(device, {
|
|
19
|
-
shaderDir: join(__dirname, "
|
|
19
|
+
shaderDir: join(__dirname, "../../shaders/rmsnorm")
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
async forward(input: Buffer, encoderShared: GPUCommandEncoder | undefined) {
|
|
@@ -48,7 +48,7 @@ export class SelfAttention {
|
|
|
48
48
|
filename: [join(configs.dirname, "LINEAR_KEY_WEIGHTS.bin"), join(configs.dirname, "LINEAR_KEY_BIAS.bin")]
|
|
49
49
|
})
|
|
50
50
|
this.gpu = new GPUManager(device, {
|
|
51
|
-
shaderDir: join(__dirname, "shaders/")
|
|
51
|
+
shaderDir: join(__dirname, "../../shaders/")
|
|
52
52
|
})
|
|
53
53
|
}
|
|
54
54
|
async softmaxBackward(weights: Buffer, dWeigths: Buffer, output: Buffer, tokenCount: number, enocder: GPUCommandEncoder) {
|
package/src/Softmax/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export class Softmax {
|
|
|
17
17
|
targetBuffer: Buffer | undefined;
|
|
18
18
|
constructor(public device: GPUDevice, public VocabSize: number) {
|
|
19
19
|
this.gpu = new GPUManager(device, {
|
|
20
|
-
shaderDir: join(__dirname,'
|
|
20
|
+
shaderDir: join(__dirname,'../../shaders/softmax')
|
|
21
21
|
})
|
|
22
22
|
}
|
|
23
23
|
async forward(logit: Buffer | number[], encoderShared: GPUCommandEncoder | undefined) {
|
|
@@ -11,7 +11,7 @@ export class residualConnection{
|
|
|
11
11
|
addShader: GPUComputePipeline | undefined;
|
|
12
12
|
constructor(public device : GPUDevice){
|
|
13
13
|
this.gpu = new GPUManager(device, {
|
|
14
|
-
shaderDir: join(__dirname, "
|
|
14
|
+
shaderDir: join(__dirname, "../../shaders")
|
|
15
15
|
})
|
|
16
16
|
}
|
|
17
17
|
async add(a: Buffer, b: Buffer){
|
|
@@ -20,6 +20,7 @@ export class residualConnection{
|
|
|
20
20
|
if(this.output) this.output.destroy()
|
|
21
21
|
this.output = await this.gpu?.createBuffer(new Float32Array(a.buffer.size / 4), "storage")
|
|
22
22
|
}
|
|
23
|
+
if(!this.addShader) this.addShader = await this.gpu?.getPiplineShader("add.wgsl")
|
|
23
24
|
const bindGroup = await this.gpu?.createBindGroup(this.addShader!, [a,b,this.output!], 0)
|
|
24
25
|
await this.gpu?.RunPipline(encoder, this.addShader!, bindGroup!, Math.ceil((a.buffer.size / 4) / 64))
|
|
25
26
|
await this.gpu?.SumbitEncoder(encoder!)
|