How to use the cupy.testing function in cupy

To help you get started, we’ve selected a few cupy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chainer / chainer / tests / cupy_tests / math_tests / test_explog.py View on Github external
def check_binary(self, name, xp, dtype):
        a = testing.shaped_arange((2, 3), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3), xp, dtype)
        return getattr(xp, name)(a, b)
github chainer / chainer / tests / cupy_tests / creation_tests / test_matrix.py View on Github external
def test_diagflat3(self, xp):
        a = testing.shaped_arange((3, 3), xp)
        return xp.diagflat(a, -2)
github chainer / chainer / tests / cupy_tests / manipulation_tests / test_join.py View on Github external
    @testing.numpy_cupy_raises()
    def test_stack_out_of_bounds(self, xp):
        a = testing.shaped_arange((2, 3), xp)
        return xp.stack([a, a], axis=3)
github chainer / chainer / tests / cupy_tests / math_tests / test_arithmetic.py View on Github external
    @testing.for_float_dtypes()
    @testing.numpy_cupy_allclose()
    def test_modf(self, xp, dtype):
        a = xp.array([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5], dtype=dtype)
        b, c = xp.modf(a)
        d = xp.empty((2, 7), dtype=dtype)
        d[0] = b
        d[1] = c
        return d
github chainer / chainer / tests / cupy_tests / core_tests / test_ndarray.py View on Github external
def test_shape_mismatch(self, xp, dtype):
        a = testing.shaped_arange(self.shape, xp, dtype)
        i = testing.shaped_arange(self.indices, xp, numpy.int32) % 3
        o = testing.shaped_arange(self.out_shape, xp, dtype)
        wrap_take(a, i, out=o)
github chainer / chainer / tests / cupy_tests / io_tests / test_npz.py View on Github external
a1 = testing.shaped_arange((2, 3, 4), dtype=dtype)
        a2 = testing.shaped_arange((3, 4, 5), dtype=dtype)

        sio = six.BytesIO()
        savez(sio, a1, a2)
        s = sio.getvalue()
        sio.close()

        sio = six.BytesIO(s)
        with cupy.load(sio) as d:
            b1 = d['arr_0']
            b2 = d['arr_1']
        sio.close()

        testing.assert_array_equal(a1, b1)
        testing.assert_array_equal(a2, b2)
github chainer / chainer / tests / cupy_tests / math_tests / test_misc.py View on Github external
def test_clip1(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        return a.clip(3, 13)
github chainer / chainer / tests / cupy_tests / core_tests / test_ndarray_reduction.py View on Github external
    @testing.for_all_dtypes()
    @testing.numpy_cupy_allclose()
    def test_max_axis1(self, xp, dtype):
        a = testing.shaped_random((2, 3, 4), xp, dtype)
        return a.max(axis=1)
github chainer / chainer / tests / cupy_tests / math_tests / test_misc.py View on Github external
    @testing.for_float_dtypes()
    @testing.numpy_cupy_array_equal()
    def check_binary_nan(self, name, xp, dtype):
        a = xp.array([-3, numpy.NAN, -1, numpy.NAN, 0, numpy.NAN, 2],
                     dtype=dtype)
        b = xp.array([numpy.NAN, numpy.NAN, 1, 0, numpy.NAN, -1, -2],
                     dtype=dtype)
        return getattr(xp, name)(a, b)
github chainer / chainer / tests / cupy_tests / core_tests / test_ndarray_get.py View on Github external
import unittest

import cupy
from cupy import cuda
from cupy import testing
import numpy
from numpy import testing as np_testing


@testing.gpu
class TestArrayGet(unittest.TestCase):

    _multiprocess_can_split_ = True

    def setUp(self):
        self.stream = cuda.Stream(null=True)

    def check_get(self, f, stream):
        a_gpu = f(cupy)
        a_cpu = a_gpu.get(stream)
        if stream:
            stream.synchronize()
        b_cpu = f(numpy)
        np_testing.assert_array_equal(a_cpu, b_cpu)

    @testing.for_all_dtypes()