(device: GPUDevice, program: WebGPUProgram, inputsData: InputInfo[],
output: TensorInfo, parallelCompilation: boolean)
| 60 | |
| 61 | export const compileProgram = |
| 62 | (device: GPUDevice, program: WebGPUProgram, inputsData: InputInfo[], |
| 63 | output: TensorInfo, parallelCompilation: boolean): GPUComputePipeline| |
| 64 | Promise<GPUComputePipeline> => { |
| 65 | const outputData = {dtype: output.dtype, shape: output.shape}; |
| 66 | const source = makeShader(inputsData, outputData, program); |
| 67 | const module = device.createShaderModule( |
| 68 | {code: source, label: program.constructor.name}); |
| 69 | |
| 70 | let printShaderString = env().get('WEBGPU_PRINT_SHADER') as string; |
| 71 | if (printShaderString !== '') { |
| 72 | printShaderString = printShaderString.toLowerCase(); |
| 73 | const printShaderArray = printShaderString.split(','); |
| 74 | if (printShaderString === 'all' || |
| 75 | printShaderArray.some( |
| 76 | item => program.shaderKey.toLowerCase().includes(item))) { |
| 77 | console.group(program.shaderKey); |
| 78 | console.debug(source); |
| 79 | console.groupEnd(); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if (parallelCompilation) { |
| 84 | return device.createComputePipelineAsync({ |
| 85 | compute: {module, entryPoint: '_start'}, |
| 86 | label: program.constructor.name, |
| 87 | layout: 'auto' |
| 88 | }); |
| 89 | } else { |
| 90 | return device.createComputePipeline({ |
| 91 | compute: {module, entryPoint: '_start'}, |
| 92 | label: program.constructor.name, |
| 93 | layout: 'auto' |
| 94 | }); |
| 95 | } |
| 96 | }; |
| 97 | |
| 98 | export const typeSnippet = (component: number, type = 'f32') => { |
| 99 | switch (component) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…