(x_0, s_0, b_0, rm_0, rv_0, m_0=0.1)
| 165 | dev = gpu_dev |
| 166 | |
| 167 | def _run_testing(x_0, s_0, b_0, rm_0, rv_0, m_0=0.1): |
| 168 | # np api |
| 169 | y_1 = _np_bn_testing(x_0, s_0, b_0, rm_0, rv_0, momentum=m_0) |
| 170 | |
| 171 | # singa api |
| 172 | hndl = singa_api.CudnnBatchNormHandle( |
| 173 | m_0, |
| 174 | tensor.Tensor(device=dev, data=x_0).data) |
| 175 | y_2_c = singa_api.GpuBatchNormForwardInference( |
| 176 | hndl, |
| 177 | tensor.Tensor(device=dev, data=x_0).data, |
| 178 | tensor.Tensor(device=dev, data=s_0).data, |
| 179 | tensor.Tensor(device=dev, data=b_0).data, |
| 180 | tensor.Tensor(device=dev, data=rm_0).data, |
| 181 | tensor.Tensor(device=dev, data=rv_0).data) |
| 182 | #print(y_1) |
| 183 | #print(tensor.to_numpy(_cTensor_to_pyTensor(y_2_c))) |
| 184 | |
| 185 | np.testing.assert_array_almost_equal( |
| 186 | y_1, tensor.to_numpy(_cTensor_to_pyTensor(y_2_c)), decimal=3) |
| 187 | return |
| 188 | |
| 189 | x_0 = np.array([1, 1, 1, 1, 2, 2, 2, 2, 10, 10, 10, 10, 20, 20, 20, 20], |
| 190 | dtype=np.float32).reshape((2, 2, 2, 2)) |
nothing calls this directly
no test coverage detected