Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #5
0
def _if_positive(result, criterion, then_, else_):
    return elementwise.get_if_positive_kernel(
            result.context, criterion.dtype, then_.dtype)
Exemple #6
0
def _if_positive(result, criterion, then_, else_):
    return elementwise.get_if_positive_kernel(result.context, criterion.dtype,
                                              then_.dtype)