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

Function insertAlignment

tfjs-backend-webgpu/src/webgpu_program.ts:829–842  ·  view source on GitHub ↗
(uniformShader: string)

Source from the content-addressed store, hash-verified

827}
828
829function insertAlignment(uniformShader: string) {
830 // insert alignment when current pattern is vec5 or vec6
831 const curInsertRe = /(\w+)\s*:\s*vec(5|6)/g;
832 uniformShader = uniformShader.replace(curInsertRe, (match) => {
833 return '@align(16) ' + match;
834 });
835
836 // insert alignment when previous pattern is vec5 or vec6
837 const preInsertRe = /vec(5|6)\s*,\s*(\w+)/g;
838 uniformShader = uniformShader.replace(preInsertRe, (_, p1, p2) => {
839 return `vec${p1}, @align(16) ${p2}`;
840 });
841 return uniformShader;
842}
843function isFlatDispatchLayout(program: WebGPUProgram): boolean {
844 if (program.dispatchLayout.hasOwnProperty('y') &&
845 program.dispatchLayout.y.length !== 0) {

Callers 1

makeShaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…