(
outputShape:
number[])
| 29 | rank: number; |
| 30 | |
| 31 | constructor( |
| 32 | outputShape: |
| 33 | number[]) { // TODO(https://github.com/tensorflow/tfjs/issues/893): |
| 34 | // Only input / output 3D tensors. |
| 35 | this.outputShape = outputShape; |
| 36 | this.rank = outputShape.length; |
| 37 | this.enableShapeUniforms = useShapeUniforms(this.outputShape.length); |
| 38 | |
| 39 | if (this.rank === 0) { |
| 40 | this.userCode = ` |
| 41 | void main() { |
| 42 | setOutput(vec4(getA(), 0., 0., 0.)); |
| 43 | } |
| 44 | `; |
| 45 | } else { |
| 46 | const channels = getChannels('rc', this.rank); |
| 47 | const dtype = getCoordsDataType(this.rank); |
| 48 | const outOfBoundsCondition = this.getOutOfBoundsCondition(channels); |
| 49 | const setup = this.getSetup(channels); |
| 50 | const output = this.getOutput(channels); |
| 51 | |
| 52 | this.userCode = ` |
| 53 | void main() { |
| 54 | ${dtype} rc = getOutputCoords(); |
| 55 | |
| 56 | if(${outOfBoundsCondition}) { |
| 57 | setOutput(vec4(0)); |
| 58 | } else { |
| 59 | ${setup} |
| 60 | |
| 61 | setOutput(vec4(${output})); |
| 62 | } |
| 63 | } |
| 64 | `; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | private getSourceCoordsArr(dims: string[]): string[] { |
| 69 | const coords = []; |
nothing calls this directly
no test coverage detected