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 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 = ''.join(('cupy.core._cub_reduction.', '_SimpleCubReductionKernel_get_cached_function')) with testing.AssertFunctionIsCalled(func): a.sum() with testing.AssertFunctionIsCalled(func): a.sum(axis=1) with testing.AssertFunctionIsCalled(func, times_called=0): a.sum(axis=0) _accelerator.set_routine_accelerators(old_routine_accelerators)
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 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 = _accelerator.get_routine_accelerators() if self.enable_cub: _accelerator.set_routine_accelerators(['cub']) else: _accelerator.set_routine_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([])