Exemplo n.º 1
0
def if_positive(criterion, then_, else_, out=None, queue=None):
    if not (criterion.shape == then_.shape == else_.shape):
        raise ValueError("shapes do not match")

    if not (then_.dtype == else_.dtype):
        raise ValueError("dtypes do not match")

    knl = elementwise.get_if_positive_kernel(criterion.context, criterion.dtype, then_.dtype)

    if out is None:
        out = empty_like(then_)
    _if_positive(out, criterion, then_, else_)
    return out
Exemplo n.º 2
0
def if_positive(criterion, then_, else_, out=None, queue=None):
    if not (criterion.shape == then_.shape == else_.shape):
        raise ValueError("shapes do not match")

    if not (then_.dtype == else_.dtype):
        raise ValueError("dtypes do not match")

    knl = elementwise.get_if_positive_kernel(criterion.context,
                                             criterion.dtype, then_.dtype)

    if out is None:
        out = empty_like(then_)
    _if_positive(out, criterion, then_, else_)
    return out
Exemplo n.º 3
0
def if_positive(criterion, then_, else_, out=None, queue=None):
    if not (criterion.shape == then_.shape == else_.shape):
        raise ValueError("shapes do not match")

    if not (then_.dtype == else_.dtype):
        raise ValueError("dtypes do not match")

    knl = elementwise.get_if_positive_kernel(criterion.context,
                                             criterion.dtype, then_.dtype)

    if out is None:
        out = empty_like(then_)

    knl(queue or criterion.queue, criterion._global_size,
        criterion._local_size, criterion.data, then_.data, else_.data,
        out.data, criterion.size)

    return out
Exemplo n.º 4
0
def if_positive(criterion, then_, else_, out=None, queue=None):
    if not (criterion.shape == then_.shape == else_.shape):
        raise ValueError("shapes do not match")

    if not (then_.dtype == else_.dtype):
        raise ValueError("dtypes do not match")

    knl = elementwise.get_if_positive_kernel(
            criterion.context,
            criterion.dtype, then_.dtype)

    if out is None:
        out = empty_like(then_)

    knl(queue or criterion.queue, criterion._global_size, criterion._local_size,
            criterion.data, then_.data, else_.data, out.data,
            criterion.size)

    return out
Exemplo n.º 5
0
def _if_positive(result, criterion, then_, else_):
    return elementwise.get_if_positive_kernel(
            result.context, criterion.dtype, then_.dtype)
Exemplo n.º 6
0
def _if_positive(result, criterion, then_, else_):
    return elementwise.get_if_positive_kernel(result.context, criterion.dtype,
                                              then_.dtype)