コード例 #1
0
ファイル: test_misc.py プロジェクト: lebedov/scikit-cuda
    def _impl_test_minmax(self, dtype):
        x = np.random.normal(scale=5.0, size=(3, 5))
        x = x.astype(dtype=dtype, order='C')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])

        x = x.astype(dtype=dtype, order='F')
        x_gpu = gpuarray.to_gpu(x)
        assert_allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
        assert_allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1),
                        rtol=dtype_to_rtol[dtype],
                        atol=dtype_to_atol[dtype])
コード例 #2
0
    def _impl_test_minmax(self, dtype):
        x = np.random.normal(scale=5.0, size=(3, 5))
        x = x.astype(dtype=dtype, order='C')
        x_gpu = gpuarray.to_gpu(x)
        assert np.allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0))
        assert np.allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1))
        assert np.allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0))
        assert np.allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1))

        x = x.astype(dtype=dtype, order='F')
        x_gpu = gpuarray.to_gpu(x)
        assert np.allclose(misc.max(x_gpu, axis=0).get(), x.max(axis=0))
        assert np.allclose(misc.max(x_gpu, axis=1).get(), x.max(axis=1))
        assert np.allclose(misc.min(x_gpu, axis=0).get(), x.min(axis=0))
        assert np.allclose(misc.min(x_gpu, axis=1).get(), x.min(axis=1))