Array#

class vulkpy.Array#

Bases: _GPUArray

GPU Array for float (32bit)

Methods Summary

abs([inplace])

Element-wise Abs

acos([inplace])

Element-wise acos()

acosh([inplace])

Element-wise acosh()

asin([inplace])

Element-wise asin()

asinh([inplace])

Element-wise asinh()

atan([inplace])

Element-wise atan()

atanh([inplace])

Element-wise atanh()

broadcast_to(shape)

Broadcast to new shape

clamp(min, max[, inplace])

Element-wise clamp()

cos([inplace])

Element-wise cos()

cosh([inplace])

Element-wise cosh()

exp([inplace])

Element-wise exp()

exp2([inplace])

Element-wise exp2()

flush()

Flush Buffer to GPU

gather(indices[, axis])

Gather values of indices

invsqrt([inplace])

Element-wise 1/sqrt()

log([inplace])

Element-wise log()

log2([inplace])

Element-wise log2()

max(other[, inplace])

Element-wise Max

maximum([axis, keepdims, rebroadcast])

Get Maximum Value

mean([axis, keepdims, rebroadcast])

Calculate Mean Value

min(other[, inplace])

Element-wise Min

minimum([axis, keepdims, rebroadcast])

Get Minimum Value

prod([axis, keepdims, rebroadcast])

Calculate Product of Elements

reshape(shape)

Reshape of this array

sign([inplace])

Element-wise sign

sin([inplace])

Element-wise sin()

sinh([inplace])

Element-wise sinh()

sqrt([inplace])

Element-wise sqrt()

sum([axis, keepdims, rebroadcast])

Calculate Sum of Elements

tan([inplace])

Element-wise tan()

tanh([inplace])

Element-wise tanh()

wait()

Wait Last Job

Methods Documentation

abs(inplace: bool = False) Array#

Element-wise Abs

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

abs array

Return type:

Array

acos(inplace: bool = False) Array#

Element-wise acos()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

acos array

Return type:

Array

acosh(inplace: bool = False) Array#

Element-wise acosh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

acosh array

Return type:

Array

asin(inplace: bool = False) Array#

Element-wise asin()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

asin array

Return type:

Array

asinh(inplace: bool = False) Array#

Element-wise asinh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

asinh array

Return type:

Array

atan(inplace: bool = False) Array#

Element-wise atan()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

atan array

Return type:

Array

atanh(inplace: bool = False) Array#

Element-wise atanh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

atanh array

Return type:

Array

broadcast_to(shape: Iterable[int]) Array#

Broadcast to new shape

Parameters:

shape (iterable of ints) – Shape of broadcast target

Returns:

Broadcasted array

Return type:

vulkpy.Array

Raises:

ValueError – If shape is not compatible.

clamp(min: Array | float, max: Array | float, inplace: bool = False) Array#

Element-wise clamp()

Parameters:
  • min (Array or float) – Minimum value

  • max (Array or float) – Maximum value

  • inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

clamped array

Return type:

Array

cos(inplace: bool = False) Array#

Element-wise cos()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

cos array

Return type:

Array

cosh(inplace: bool = False) Array#

Element-wise cosh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

cosh array

Return type:

Array

exp(inplace: bool = False) Array#

Element-wise exp()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

exp array

Return type:

Array

exp2(inplace: bool = False) Array#

Element-wise exp2()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

exp2 array

Return type:

Array

flush()#

Flush Buffer to GPU

gather(indices: U32Array, axis: int | None = None) Array#

Gather values of indices

Parameters:
  • indices (vulkpy.U32Array) – Indices

  • axis (int, optional) – Axis of gather. If None (default), array is flattened beforehand.

Returns:

Gathered array

Return type:

vulkpy.Array

invsqrt(inplace: bool = False) Array#

Element-wise 1/sqrt()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

1/sqrt array

Return type:

Array

log(inplace: bool = False) Array#

Element-wise log()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

log array

Return type:

Array

log2(inplace: bool = False) Array#

Element-wise log2()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

log2 array

Return type:

Array

max(other: Array | float, inplace: bool = False) Array#

Element-wise Max

Parameters:
  • other (Array or float) – Other value

  • inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

max array

Return type:

Array

Raises:

ValueError – If shape is not same.

maximum(axis: None | int | Iterable[int] = None, keepdims: bool = False, rebroadcast: bool = False) Array#

Get Maximum Value

Parameters:
  • axis (int, optional) – Reduction axis

  • keepdims (bool, optional) – When True, reduced dimensions are keeped with size one. Default is False.

  • rebroadcast (bool, optional) – When True, keep shape by re-broadcasting after reduce. Default is False.

Returns:

Maximum array

Return type:

vulkpy.Array

mean(axis: None | int | Iterable[int] = None, keepdims: bool = False, rebroadcast: bool = False) Array#

Calculate Mean Value

Parameters:
  • axis (int, optional) – Reduction axis

  • keepdims (bool, optional) – When True, reduced dimensions are keeped with size one. Default is False.

  • rebroadcast (bool, optional) – When True, keep shape by re-broadcasting after reduce. Default is False.

Returns:

Mean array

Return type:

vulkpy.Array

min(other: Array | float, inplace: bool = False) Array#

Element-wise Min

Parameters:
  • other (Array or float) – Other value

  • inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

min array

Return type:

Array

Raises:

ValueError – If shape is not same.

minimum(axis: None | int | Iterable[int] = None, keepdims: bool = False, rebroadcast: bool = False) Array#

Get Minimum Value

Parameters:
  • axis (int, optional) – Reduction axis

  • keepdims (bool, optional) – When True, reduced dimensions are keeped with size one. Default is False.

  • rebroadcast (bool, optional) – When True, keep shape by re-broadcasting after reduce. Default is False.

Returns:

Minimum array

Return type:

vulkpy.Array

prod(axis: None | int | Iterable[int] = None, keepdims: bool = False, rebroadcast: bool = False) Array#

Calculate Product of Elements

Parameters:
  • axis (int, optional) – Reduction axis

  • keepdims (bool, optional) – When True, reduced dimensions are keeped with size one. Default is False.

  • rebroadcast (bool, optional) – When True, keep shape by re-broadcasting after reduce. Default is False.

Returns:

Producted array

Return type:

vulkpy.Array

reshape(shape: Iterable[int])#

Reshape of this array

Parameters:

shape (iterable of int) – New shape

Raises:

ValueError – If shape is incompatible

sign(inplace: bool = False) Array#

Element-wise sign

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

sign array

Return type:

Array

sin(inplace: bool = False) Array#

Element-wise sin()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

sin array

Return type:

Array

sinh(inplace: bool = False) Array#

Element-wise sinh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

sinh array

Return type:

Array

sqrt(inplace: bool = False) Array#

Element-wise sqrt()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

sqrt array

Return type:

Array

sum(axis: None | int | Iterable[int] = None, keepdims: bool = False, rebroadcast: bool = False) Array#

Calculate Sum of Elements

Parameters:
  • axis (int, optional) – Reduction axis

  • keepdims (bool, optional) – When True, reduced dimensions are keeped with size one. Default is False.

  • rebroadcast (bool, optional) – When True, keep shape by re-broadcasting after reduce. Default is False.

Returns:

Summarized array

Return type:

vulkpy.Array

tan(inplace: bool = False) Array#

Element-wise tan()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

tan array

Return type:

Array

tanh(inplace: bool = False) Array#

Element-wise tanh()

Parameters:

inplace (bool) – If True, update inplace, otherwise returns new array. Default value is False.

Returns:

tanh array

Return type:

Array

wait()#

Wait Last Job

__init__(gpu: GPU, *, data=None, shape: Iterable[int] | None = None)#

Initialize Array

Parameters:
  • gpu (GPU) – GPU instance to allocate at.

  • data (array_like, optional) – Data which copy to GPU buffer.

  • shape (array_like, optional) – Array shape

Raises:

ValueError – If both data and shape are None.