@mineproness/tensorloop 1.5.6 → 1.5.7
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 +1 -1
- package/readme.md +1 -0
- package/src/GPU.js +15 -1
- package/src/Linear/index.js +3 -2
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -15,6 +15,7 @@ A high-performance JavaScript library that provides essential AI and Large Langu
|
|
|
15
15
|
- **Text Processing**: Built-in **Tokenizer** to convert raw text into token IDs and back.
|
|
16
16
|
- **Special Tokens**: Native support for `<PAD>` and `<EOS>`.
|
|
17
17
|
- **FFN BLOCK**: It add a layer to understand Complex Patterns.
|
|
18
|
+
- ***GPU SUPPORT** GPU Can support it without any configure
|
|
18
19
|
---
|
|
19
20
|
|
|
20
21
|
## 🏗 Core Architecture
|
package/src/GPU.js
CHANGED
|
@@ -104,7 +104,6 @@ export class GPULinear {
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
|
|
108
107
|
}
|
|
109
108
|
CalculateLinearForward(input) {
|
|
110
109
|
const result = []
|
|
@@ -123,10 +122,25 @@ export class GPULinear {
|
|
|
123
122
|
for (let i = 0; i < outGradient.length; i++) {
|
|
124
123
|
inputGradient[i] += outGradient[i]
|
|
125
124
|
}
|
|
125
|
+
const oldW = this.Weights[a]
|
|
126
|
+
const oldB = this.Bias[a]
|
|
126
127
|
this.Weights[a] = this.cacheLBWeights[a](this.Weights[a], out, input, learningRate)
|
|
127
128
|
this.Bias[a] = this.cacheLBIas[a](this.Bias[a], out, learningRate)
|
|
129
|
+
if(oldW && typeof oldW.delete === "function"){
|
|
130
|
+
oldW.delete()
|
|
131
|
+
}
|
|
132
|
+
if(oldB && typeof oldB.delete === "function"){
|
|
133
|
+
oldB.delete()
|
|
134
|
+
}
|
|
128
135
|
|
|
129
136
|
}
|
|
130
137
|
return inputGradient
|
|
131
138
|
}
|
|
139
|
+
GetWeightsAndBias(){
|
|
140
|
+
const weight = []
|
|
141
|
+
const bias = []
|
|
142
|
+
this.Weights.map((e)=> weight.push(...e.toArray()))
|
|
143
|
+
this.Bias.map((e)=> bias.push(...e.toArray()))
|
|
144
|
+
return { weights: weight, bias: new Float32Array(bias)}
|
|
145
|
+
}
|
|
132
146
|
}
|
package/src/Linear/index.js
CHANGED
|
@@ -44,8 +44,9 @@ export class Linear {
|
|
|
44
44
|
this.gpu.InitKernel(this.Weights, this.Bias, embeddingSize)
|
|
45
45
|
}
|
|
46
46
|
Save() {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const {bias, weights} = this.gpu.GetWeightsAndBias()
|
|
48
|
+
SaveVectors(weights, this.configs.save.filename[0])
|
|
49
|
+
SaveBias(bias, this.configs.save.filename[1])
|
|
49
50
|
}
|
|
50
51
|
forward(input) {
|
|
51
52
|
this.input.push(input)
|