(dy: T, saved: Tensor[])
| 1188 | }; |
| 1189 | |
| 1190 | const backwardsFunc = (dy: T, saved: Tensor[]) => { |
| 1191 | const gradRes = res.gradFunc(dy, saved); |
| 1192 | const grads: Tensor[] = Array.isArray(gradRes) ? gradRes : [gradRes]; |
| 1193 | util.assert( |
| 1194 | grads.length === inputs.length, |
| 1195 | () => 'The function f passed in customGrad(f) must return an ' + |
| 1196 | 'object where `obj.gradFunc` is a function that returns ' + |
| 1197 | 'the same number of tensors as inputs passed to f(...).'); |
| 1198 | util.assert( |
| 1199 | grads.every(t => t instanceof Tensor), |
| 1200 | () => 'The function f passed in customGrad(f) must return an ' + |
| 1201 | 'object where `obj.gradFunc` is a function that returns ' + |
| 1202 | 'a list of only tensors.'); |
| 1203 | const gradMap: {[key: string]: () => Tensor} = {}; |
| 1204 | grads.forEach((grad, i) => { |
| 1205 | gradMap[i] = () => grad; |
| 1206 | }); |
| 1207 | return gradMap; |
| 1208 | }; |
| 1209 | |
| 1210 | return this.runKernelFunc({ |
| 1211 | forwardFunc, |
nothing calls this directly
no outgoing calls
no test coverage detected