(self, x, in_place, gc, dc)
| 169 | @given(x=hu.tensor(), in_place=st.booleans(), **hu.gcs) |
| 170 | @settings(deadline=10000) |
| 171 | def test_gradient(self, x, in_place, gc, dc): |
| 172 | def f(inputs, outputs): |
| 173 | outputs[0].reshape(inputs[0].shape) |
| 174 | outputs[0].data[...] = inputs[0].data * 2 |
| 175 | |
| 176 | def grad_f(inputs, outputs): |
| 177 | # Ordering is [inputs, outputs, grad_outputs] |
| 178 | grad_output = inputs[2] |
| 179 | |
| 180 | grad_input = outputs[0] |
| 181 | grad_input.reshape(grad_output.shape) |
| 182 | grad_input.data[...] = grad_output.data * 2 |
| 183 | |
| 184 | op = CreatePythonOperator( |
| 185 | f, ["x"], ["x" if in_place else "y"], grad_f=grad_f) |
| 186 | self.assertGradientChecks(gc, op, [x], 0, [0]) |
| 187 | self.assertDeviceChecks(dc, op, [x], [0]) |
| 188 | |
| 189 | @given(inputs=hu.tensors(n=2), **hu.gcs) |
| 190 | @settings(deadline=10000) |
nothing calls this directly
no test coverage detected