(
xShape: number[], paddings: Array<[number, number]>,
constantValue: number)
| 25 | customUniforms = [{name: 'value', type: 'float' as UniformType}]; |
| 26 | |
| 27 | constructor( |
| 28 | xShape: number[], paddings: Array<[number, number]>, |
| 29 | constantValue: number) { |
| 30 | this.outputShape = paddings.map( |
| 31 | (p, i) => p[0] /* beforePad */ + xShape[i] + p[1] /* afterPad */); |
| 32 | const rank = xShape.length; |
| 33 | const type = getCoordsDataType(rank); |
| 34 | |
| 35 | const start = paddings.map(p => p[0]).join(','); |
| 36 | const end = paddings.map((p, i) => p[0] + xShape[i]).join(','); |
| 37 | const unpackedCoords = |
| 38 | ['coords[0]', 'coords[1]', 'coords[2]', 'coords[3]'].slice(0, rank); |
| 39 | |
| 40 | if (rank === 1) { |
| 41 | this.userCode = ` |
| 42 | int start = ${start}; |
| 43 | int end = ${end}; |
| 44 | |
| 45 | void main() { |
| 46 | int outC = getOutputCoords(); |
| 47 | if (outC < start || outC >= end) { |
| 48 | setOutput(value); |
| 49 | } else { |
| 50 | setOutput(getX(outC - start)); |
| 51 | } |
| 52 | } |
| 53 | `; |
| 54 | return; |
| 55 | } |
| 56 | this.userCode = ` |
| 57 | ${type} start = ${type}(${start}); |
| 58 | ${type} end = ${type}(${end}); |
| 59 | |
| 60 | void main() { |
| 61 | ${type} outC = getOutputCoords(); |
| 62 | if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { |
| 63 | setOutput(value); |
| 64 | } else { |
| 65 | ${type} coords = outC - start; |
| 66 | setOutput(getX(${unpackedCoords})); |
| 67 | } |
| 68 | } |
| 69 | `; |
| 70 | } |
| 71 | } |
nothing calls this directly
no test coverage detected