| 19 | import {computeDispatch, flatDispatchLayout} from './webgpu_util'; |
| 20 | |
| 21 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…