(
program: WebGPUProgram, inputsData: InputInfo[],
output: TensorInfo)
| 348 | } |
| 349 | |
| 350 | export function makeShaderKey<R extends Rank>( |
| 351 | program: WebGPUProgram, inputsData: InputInfo[], |
| 352 | output: TensorInfo): string { |
| 353 | let key = program.shaderKey; |
| 354 | if (program.pixelsOpType != null) { |
| 355 | return key; |
| 356 | } |
| 357 | |
| 358 | const shapes: number[][] = []; |
| 359 | const types: Array<keyof DataTypeMap> = []; |
| 360 | inputsData.forEach(element => { |
| 361 | shapes.push(element.shape); |
| 362 | types.push(element.dtype); |
| 363 | }); |
| 364 | shapes.push(output.shape); |
| 365 | types.push(output.dtype); |
| 366 | |
| 367 | const broadcastDims = |
| 368 | inputsData.map(d => backend_util.getBroadcastDims(d.shape, output.shape)); |
| 369 | const inputShapesEqualsOutShape = |
| 370 | inputsData.map(d => util.arraysEqual(d.shape, output.shape)).join('_'); |
| 371 | const broadcastDimsKey = broadcastDims.map(d => d.join('_')).join(';'); |
| 372 | |
| 373 | const flatDispatchString = isFlatDispatch(program) ? 'flatDispatch' : ''; |
| 374 | |
| 375 | key += '_' + (program.workgroupSize ? program.workgroupSize.join(',') : '') + |
| 376 | shapes.map(shape => shape.length).join(',') + types.join(',') + |
| 377 | program.variableNames.join(',') + broadcastDimsKey + |
| 378 | inputShapesEqualsOutShape + flatDispatchString; |
| 379 | |
| 380 | return key; |
| 381 | } |
| 382 | |
| 383 | const commonSnippet = ` |
| 384 | struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32}; |
nothing calls this directly
no test coverage detected
searching dependent graphs…