MCPcopy Create free account
hub / github.com/0hq/WebGPT / newInstance

Method newInstance

instructions.js:567–588  ·  view source on GitHub ↗
(rows, cols, inputBuffer, transpose = false)

Source from the content-addressed store, hash-verified

565 }
566
567 newInstance(rows, cols, inputBuffer, transpose = false) {
568 const workgroupsX = cols > 4096 ? 256 : 64;
569 const fusedPipeline = this.getFusedPipeline(workgroupsX, transpose);
570
571 const uniformBuffer = this.initUniform(4, [[0, new Uint32Array([rows, cols])]]);
572 const resultBuffer = this.initResultBuffer([rows, cols], `${this.name}_ResultBuffer_`);
573 const bindGroup = this.initBindGroup(this.u_s_Layout, [uniformBuffer, resultBuffer], `${this.name}_BindGroup_`);
574 const inputBindGroup = this.initBindGroup(this.r_Layout, [inputBuffer], `${this.name}_BindGroup__Input`);
575 const workgroups = { x: 1, y: wgSize(rows, 1), z: 1 };
576
577 return {
578 resultBuffer: resultBuffer,
579 passes: [
580 {
581 flag: "compute",
582 pipeline: fusedPipeline,
583 groups: [bindGroup, inputBindGroup],
584 workgroups: workgroups,
585 },
586 ],
587 };
588 }
589
590 /*
591 Possible improvements: Vectorization? Modify input buffer to coalesce better?

Callers

nothing calls this directly

Calls 5

getFusedPipelineMethod · 0.95
initUniformMethod · 0.80
initResultBufferMethod · 0.80
wgSizeFunction · 0.70
initBindGroupMethod · 0.45

Tested by

no test coverage detected