()
| 45 | } |
| 46 | |
| 47 | getUserCode(): string { |
| 48 | const dtype = getCoordsDataType(this.outputShape.length); |
| 49 | const switched = getSwitchedCoords(this.newDim); |
| 50 | |
| 51 | const userCode = ` |
| 52 | ${main('index')} { |
| 53 | for(var i = 0; i < ${this.workPerThread}; i = i + 1) { |
| 54 | let flatIndex = index * ${this.workPerThread} + i; |
| 55 | if(flatIndex < uniforms.size) { |
| 56 | let coords = getCoordsFromIndex(flatIndex); |
| 57 | setOutputAtIndex(flatIndex, A[getIndexFromCoords${ |
| 58 | this.outputShape.length}D( |
| 59 | ${dtype}(${switched}), uniforms.aShape)]); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | `; |
| 64 | return userCode; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | export function getSwitchedCoords(newDim: number[]): string { |
nothing calls this directly
no test coverage detected