def setUp(self): self.old_routine_accelerators = _acc.get_routine_accelerators() self.old_reduction_accelerators = _acc.get_reduction_accelerators() if self.backend == 'device': _acc.set_routine_accelerators(['cub']) _acc.set_reduction_accelerators([]) elif self.backend == 'block': _acc.set_routine_accelerators([]) _acc.set_reduction_accelerators(['cub'])
def setUp(self): cupy._core._optimize_config._clear_all_contexts_cache() self.old_reductions = _accelerator.get_reduction_accelerators() _accelerator.set_reduction_accelerators(self.backend) # avoid shadowed by the cub module self.old_routines = _accelerator.get_routine_accelerators() _accelerator.set_routine_accelerators([]) self.x = testing.shaped_arange((3, 4), cupy, dtype=cupy.float32)
def setUp(self): self.order, self.axis = self.order_and_axis self.old_routine_accelerators = _acc.get_routine_accelerators() self.old_reduction_accelerators = _acc.get_reduction_accelerators() if self.backend == 'device': if self.axis is not None: raise unittest.SkipTest('does not support') _acc.set_routine_accelerators(['cub']) _acc.set_reduction_accelerators([]) elif self.backend == 'block': _acc.set_routine_accelerators([]) _acc.set_reduction_accelerators(['cub'])
def with_accelerators(self): old_accelerators = _accelerator.get_routine_accelerators() if self.enable_cub: _accelerator.set_routine_accelerators(['cub']) else: _accelerator.set_routine_accelerators([]) yield _accelerator.set_routine_accelerators(old_accelerators)
def test_can_use_accelerator_set_unset(self): # ensure we use CUB block reduction and not CUB device reduction old_routine_accelerators = _accelerator.get_routine_accelerators() _accelerator.set_routine_accelerators([]) a = cupy.random.random((10, 10)) # this is the only function we can mock; the rest is cdef'd func_name = ''.join(('cupy._core._cub_reduction.', '_SimpleCubReductionKernel_get_cached_function')) func = _cub_reduction._SimpleCubReductionKernel_get_cached_function with testing.AssertFunctionIsCalled(func_name, wraps=func, times_called=2): # two passes a.sum() with testing.AssertFunctionIsCalled(func_name, wraps=func, times_called=1): # one pass a.sum(axis=1) with testing.AssertFunctionIsCalled(func_name, wraps=func, times_called=0): # not used a.sum(axis=0) _accelerator.set_routine_accelerators(old_routine_accelerators)
def setUp(self): self.order, self.axis = self.order_and_axis old_routine_accelerators = _acc.get_routine_accelerators() old_reduction_accelerators = _acc.get_reduction_accelerators() if self.backend == 'device': if self.axis is not None: pytest.skip('does not support') _acc.set_routine_accelerators(['cub']) _acc.set_reduction_accelerators([]) elif self.backend == 'block': _acc.set_routine_accelerators([]) _acc.set_reduction_accelerators(['cub']) yield _acc.set_routine_accelerators(old_routine_accelerators) _acc.set_reduction_accelerators(old_reduction_accelerators)
def tearDown(self): _accelerator.set_routine_accelerators(self.old_accelerators)
def setUp(self): self.old_accelerators = _accelerator.get_routine_accelerators() _accelerator.set_routine_accelerators(['cub'])
def tearDown(self): _acc.set_routine_accelerators(self.old_routine_accelerators) _acc.set_reduction_accelerators(self.old_reduction_accelerators)
def setUp(self): self.old_accelerators = _acc.get_routine_accelerators() _acc.set_routine_accelerators([]) # also avoid fallback to CUB via the general reduction kernel self.old_reduction_accelerators = _acc.get_reduction_accelerators() _acc.set_reduction_accelerators([])