(mode)
| 112 | |
| 113 | |
| 114 | function threeLayerDeepFloat(mode) { |
| 115 | const gpu = new GPU({ mode }); |
| 116 | function child1Function(child1FunctionArgument1) { |
| 117 | return child2Function(child1FunctionArgument1); |
| 118 | } |
| 119 | function child2Function(child2FunctionArgument1) { |
| 120 | return child3Function(child2FunctionArgument1 + 1); |
| 121 | } |
| 122 | function child3Function(child3FunctionArgument1) { |
| 123 | return child3FunctionArgument1 + 1; |
| 124 | } |
| 125 | gpu |
| 126 | .addFunction(child1Function) |
| 127 | .addFunction(child2Function) |
| 128 | .addFunction(child3Function); |
| 129 | const kernel = gpu.createKernel(function(kernelArgument1) { |
| 130 | return child1Function(kernelArgument1); |
| 131 | }, { output: [1] }); |
| 132 | sinon.spy(FunctionBuilder.prototype, 'lookupReturnType'); |
| 133 | try { |
| 134 | const result = kernel(1.5); |
| 135 | assert.equal(result[0], 3.5); |
| 136 | assert.equal(FunctionBuilder.prototype.lookupReturnType.callCount, 5); |
| 137 | assert.equal(FunctionBuilder.prototype.lookupReturnType.args[0][0], 'child1Function'); |
| 138 | assert.equal(FunctionBuilder.prototype.lookupReturnType.args[1][0], 'child2Function'); |
| 139 | assert.equal(FunctionBuilder.prototype.lookupReturnType.args[2][0], 'child3Function'); |
| 140 | assert.equal(FunctionBuilder.prototype.lookupReturnType.args[3][0], 'child2Function'); |
| 141 | assert.equal(FunctionBuilder.prototype.lookupReturnType.args[4][0], 'child3Function'); |
| 142 | } finally { |
| 143 | FunctionBuilder.prototype.lookupReturnType.restore(); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | (GPU.isWebGLSupported ? test : skip)('three layer deep float WebGL', () => { |
| 148 | threeLayerDeepFloat('webgl'); |
no test coverage detected
searching dependent graphs…