@mineproness/tensorloop 2.1.56 → 2.1.58
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/src/OperationManager.js +14 -10
package/package.json
CHANGED
package/src/OperationManager.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
+
import path, { join, dirname, format } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
2
6
|
|
|
3
7
|
export class OperationManager {
|
|
4
8
|
device;
|
|
@@ -38,7 +42,7 @@ export class OperationManager {
|
|
|
38
42
|
return result
|
|
39
43
|
}
|
|
40
44
|
getShaderPipline(filename, value = { "embedding": 123 }, entryPoint = "main") {
|
|
41
|
-
let readShaderCode = fs.readFileSync(filename, "utf-8");
|
|
45
|
+
let readShaderCode = fs.readFileSync(path.join(__dirname, `../${filename}`), "utf-8");
|
|
42
46
|
if (value) {
|
|
43
47
|
for (const a in value) {
|
|
44
48
|
readShaderCode = readShaderCode.replaceAll(`%${a}%`, value[a])
|
|
@@ -63,10 +67,10 @@ export class OperationManager {
|
|
|
63
67
|
const pass = encoder.beginComputePass();
|
|
64
68
|
pass.setPipeline(pipline)
|
|
65
69
|
pass.setBindGroup(0, binding)
|
|
66
|
-
pass.dispatchWorkgroups(dispatchWorkgroups, y
|
|
70
|
+
pass.dispatchWorkgroups(dispatchWorkgroups, y, z)
|
|
67
71
|
pass.end()
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
|
|
70
74
|
async MakeACopyBuffer(encoder, sourceBuffer) {
|
|
71
75
|
const buffer = this.device.createBuffer({
|
|
72
76
|
size: sourceBuffer.size,
|
|
@@ -75,22 +79,22 @@ export class OperationManager {
|
|
|
75
79
|
encoder.copyBufferToBuffer(sourceBuffer, 0, buffer, 0, sourceBuffer.size);
|
|
76
80
|
return buffer
|
|
77
81
|
}
|
|
78
|
-
CreateEncoder(){
|
|
82
|
+
CreateEncoder() {
|
|
79
83
|
return this.device.createCommandEncoder()
|
|
80
84
|
}
|
|
81
|
-
createBindGroup(shader,groupNum,ent){
|
|
85
|
+
createBindGroup(shader, groupNum, ent) {
|
|
82
86
|
return this.device.createBindGroup({
|
|
83
87
|
layout: shader.getBindGroupLayout(groupNum),
|
|
84
|
-
entries: ent.map((e, x)=>{
|
|
88
|
+
entries: ent.map((e, x) => {
|
|
85
89
|
return {
|
|
86
|
-
binding
|
|
87
|
-
resource: e
|
|
90
|
+
binding: x,
|
|
91
|
+
resource: e
|
|
88
92
|
}
|
|
89
93
|
})
|
|
90
94
|
})
|
|
91
95
|
}
|
|
92
|
-
async submitQueue(encoder){
|
|
93
|
-
|
|
96
|
+
async submitQueue(encoder) {
|
|
97
|
+
this.device.queue.submit([encoder.finish()])
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
}
|