MCPcopy Create free account
hub / github.com/tensorflow/tfjs / makeShaderKey

Function makeShaderKey

tfjs-backend-webgpu/src/webgpu_program.ts:350–381  ·  view source on GitHub ↗
(
    program: WebGPUProgram, inputsData: InputInfo[],
    output: TensorInfo)

Source from the content-addressed store, hash-verified

348}
349
350export 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
383const commonSnippet = `
384 struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32};

Callers

nothing calls this directly

Calls 3

isFlatDispatchFunction · 0.85
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…