MCPcopy Index your code
hub / github.com/tensorflow/tfjs / FlipLeftRightProgram

Class FlipLeftRightProgram

tfjs-backend-webgpu/src/flip_left_right_webgpu.ts:21–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19import {computeDispatch, flatDispatchLayout} from './webgpu_util';
20
21export class FlipLeftRightProgram implements WebGPUProgram {
22 outputShape: number[] = [];
23 shaderKey: string;
24 dispatchLayout: {x: number[]};
25 dispatch: [number, number, number];
26 variableNames = ['x'];
27 workgroupSize: [number, number, number] = [64, 1, 1];
28 size = true;
29
30 constructor(imageShape: [number, number, number, number]) {
31 this.outputShape = imageShape;
32 this.dispatchLayout = flatDispatchLayout(this.outputShape);
33 this.dispatch = computeDispatch(
34 this.dispatchLayout, this.outputShape, this.workgroupSize);
35 this.shaderKey = 'flipLeftRight';
36 }
37
38 getUserCode(): string {
39 const userCode = `
40 ${main('index')} {
41 if (index < uniforms.size) {
42 let coords = getCoordsFromIndex(index);
43 let coordX = uniforms.xShape[2] - coords[2] - 1;
44 let outputValue = getX(coords[0], coords[1], coordX, coords[3]);
45 setOutputAtIndex(index, outputValue);
46 }
47 }
48 `;
49 return userCode;
50 }
51}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…