Spaces:
Running
Running
| export async function initGPU() { | |
| if (!navigator.gpu) { | |
| return { mode: "cpu" }; | |
| } | |
| const adapter = await navigator.gpu.requestAdapter(); | |
| const device = await adapter.requestDevice(); | |
| return { mode: "gpu", device }; | |
| } | |
| export function createCompute(device, code) { | |
| return device.createComputePipeline({ | |
| layout: "auto", | |
| compute: { | |
| module: device.createShaderModule({ code }), | |
| entryPoint: "main" | |
| } | |
| }); | |
| } |