(x,y,decimal=6)
| 30 | from cuda_helper import gpu_dev, cpu_dev |
| 31 | |
| 32 | def assertTensorEqual(x,y,decimal=6): |
| 33 | assert x.shape == y.shape |
| 34 | assert x.dtype == y.dtype |
| 35 | assert x.device.id() == y.device.id() |
| 36 | d = x.device |
| 37 | x.to_host() |
| 38 | y.to_host() |
| 39 | np.testing.assert_array_almost_equal( |
| 40 | x.data.GetFloatValue(int(x.size())), |
| 41 | y.data.GetFloatValue(int(y.size())), |
| 42 | decimal) |
| 43 | x.to_device(d) |
| 44 | y.to_device(d) |
| 45 | |
| 46 | def on_cpu_gpu(func): |
| 47 | @functools.wraps(func) |
no test coverage detected