from cupy import reduction def all(a, axis=None, out=None, keepdims=False): return _all(a, axis=axis, out=out, keepdims=keepdims) def any(a, axis=None, out=None, keepdims=False): return _any(a, axis=axis, out=out, keepdims=keepdims) _all = reduction.create_reduction_func( 'cupy_all', ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?', 'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'), ('in0', 'a & b', 'out0 = a', 'bool'), 'true', '') _any = reduction.create_reduction_func( 'cupy_any', ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?', 'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'), ('in0', 'a | b', 'out0 = a', 'bool'), 'false', '')
def nanmean(a, axis=None, dtype=None, out=None, keepdims=False): # TODO(beam2d): Implement it raise NotImplementedError def nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): # TODO(beam2d): Implement it raise NotImplementedError def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): # TODO(beam2d): Implement it raise NotImplementedError def _count_reduce_items(arr, axis): items = 1 for ax in axis: items *= arr.shape[ax] return items # TODO(okuta) needs cast _mean = reduction.create_reduction_func( 'cupy_mean', ['?->d', 'B->d', 'h->d', 'H->d', 'i->d', 'I->d', 'l->d', 'L->d', 'q->d', 'Q->d', ('e->e', (None, None, None, 'float')), 'f->f', 'd->d'], ('in0', 'a + b', 'out0 = a / (_in_ind.size() / _out_ind.size())', None))
def setUp(self): self.my_int8_sum = reduction.create_reduction_func( 'my_sum', ('b->b',), ('in0', 'a + b', 'out0 = a', None))
from cupy import reduction def count_nonzero(x): """Counts the number of non-zero values in the array. Args: x (cupy.ndarray): The array for which to count non-zeros. Returns: int: Number of non-zero values in the array. """ return int(_count_nonzero(x)) _count_nonzero = reduction.create_reduction_func( 'cupy_count_nonzero', ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l', 'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'), ('in0', 'a + b', 'out0 = (a != 0)', None), 0)
def ediff1d(ary, to_end=None, to_begin=None): # TODO(beam2d): Implement it raise NotImplementedError def gradient(f, *varargs, **kwargs): # TODO(beam2d): Implement it raise NotImplementedError def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None): # TODO(beam2d): Implement it raise NotImplementedError def trapz(y, x=None, dx=1.0, axis=-1): # TODO(beam2d): Implement it raise NotImplementedError _sum = reduction.create_reduction_func('cupy_sum', [ '?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L', 'q->q', 'Q->Q', ('e->e', (None, None, None, 'float')), 'f->f', 'd->d' ], ('in0', 'a + b', 'out0 = a', None), 0) _prod = reduction.create_reduction_func('cupy_prod', [ '?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L', 'q->q', 'Q->Q', ('e->e', (None, None, None, 'float')), 'f->f', 'd->d' ], ('in0', 'a * b', 'out0 = a', None), 1)
from cupy import reduction def count_nonzero(x): """Counts the number of non-zero values in the array. Args: x (cupy.ndarray): The array for which to count non-zeros. Returns: int: Number of non-zero values in the array. """ return int(_count_nonzero(x)) _count_nonzero = reduction.create_reduction_func( 'cupy_count_nonzero', ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l', 'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'), ('in0 != 0', 'a + b', 'out0 = a', None), 0)
# TODO(beam2d): Implement it raise NotImplementedError def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None): # TODO(beam2d): Implement it raise NotImplementedError def trapz(y, x=None, dx=1.0, axis=-1): # TODO(beam2d): Implement it raise NotImplementedError _sum = reduction.create_reduction_func( 'cupy_sum', ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L', 'q->q', 'Q->Q', ('e->e', (None, None, None, 'float')), 'f->f', 'd->d'], ('in0', 'a + b', 'out0 = a', None), 0) _prod = reduction.create_reduction_func( 'cupy_prod', ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L', 'q->q', 'Q->Q', ('e->e', (None, None, None, 'float')), 'f->f', 'd->d'], ('in0', 'a * b', 'out0 = a', None), 1)