Skip to Content
APIArray

array

View the code on GitHub 

Structs

Struct: Array

Fields

  • device_array: ArcPointer[DeviceArray]

Methods

__init__(out self, device_array: ArcPointer[DeviceArray])
Args
  • device_array: ArcPointer[DeviceArray]

  • self: Self

Returns
  • Self
__init__(out self, device_array: DeviceArray)
Args
  • device_array: DeviceArray

  • self: Self

Returns
  • Self
__del__(owned self)
Args
  • self: Self
__getitem__(self, *slices: Slice) -> Self
Args
  • self: Self

  • *slices: Slice

Returns
  • Self
__neg__(self) -> Self
Args
  • self: Self
Returns
  • Self
__add__(self, other: Self) -> Self
Args
  • self: Self

  • other: Self

Returns
  • Self
__add__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__add__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__sub__(self, other: Self) -> Self
Args
  • self: Self

  • other: Self

Returns
  • Self
__sub__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__sub__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__mul__(self, other: Self) -> Self
Args
  • self: Self

  • other: Self

Returns
  • Self
__mul__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__mul__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__matmul__(self, other: Self) -> Self
Args
  • self: Self

  • other: Self

Returns
  • Self
__truediv__(self, other: Self) -> Self
Args
  • self: Self

  • other: Self

Returns
  • Self
__truediv__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__truediv__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__pow__(self, exp: DeviceArray) -> Self
Args
  • self: Self

  • exp: DeviceArray

Returns
  • Self
__pow__(self, exp: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • exp: SIMD[dtype, 1]

Returns
  • Self
__pow__(self, exp: Int) -> Self
Args
  • self: Self

  • exp: Int

Returns
  • Self
__radd__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__radd__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__rsub__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__rsub__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__rmul__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__rmul__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__rtruediv__(self, other: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • other: SIMD[dtype, 1]

Returns
  • Self
__rtruediv__(self, other: Int) -> Self
Args
  • self: Self

  • other: Int

Returns
  • Self
__rpow__(self, exp: SIMD[dtype, 1]) -> Self
Args
  • self: Self

  • exp: SIMD[dtype, 1]

Returns
  • Self
__rpow__(self, exp: Int) -> Self
Args
  • self: Self

  • exp: Int

Returns
  • Self
__iadd__(mut self, other: Self)
Args
  • self: Self

  • other: Self

__iadd__(mut self, other: SIMD[dtype, 1])
Args
  • self: Self

  • other: SIMD[dtype, 1]

__iadd__(mut self, other: Int)
Args
  • self: Self

  • other: Int

__isub__(mut self, other: Self)
Args
  • self: Self

  • other: Self

__isub__(mut self, other: SIMD[dtype, 1])
Args
  • self: Self

  • other: SIMD[dtype, 1]

__isub__(mut self, other: Int)
Args
  • self: Self

  • other: Int

__imul__(mut self, other: Self)
Args
  • self: Self

  • other: Self

__imul__(mut self, other: SIMD[dtype, 1])
Args
  • self: Self

  • other: SIMD[dtype, 1]

__imul__(mut self, other: Int)
Args
  • self: Self

  • other: Int

__itruediv__(mut self, other: Self)
Args
  • self: Self

  • other: Self

__itruediv__(mut self, other: SIMD[dtype, 1])
Args
  • self: Self

  • other: SIMD[dtype, 1]

__itruediv__(mut self, other: Int)
Args
  • self: Self

  • other: Int

to_max[dtype: DType](self) -> Tensor[dtype]
Args
  • self: Self
Returns
  • Tensor[dtype]
tangent(self) -> Self
Args
  • self: Self
Returns
  • Self
cotangent(self) -> Self
Args
  • self: Self
Returns
  • Self
grad(self) -> Self
Args
  • self: Self
Returns
  • Self
zero_tangent(mut self)
Args
  • self: Self
zero_cotangent(mut self)
Args
  • self: Self
zero_grad(mut self)
Args
  • self: Self
__str__(self) -> String
Args
  • self: Self
Returns
  • String
write_to[W: Writer](self, mut writer: W)
Args
  • self: Self

  • writer: W

no_tangent(mut self)
Args
  • self: Self
checkpoint(mut self, value: Bool = True)
Args
  • self: Self

  • value: Bool (default: True)

requires_pullback(self) -> Bool
Args
  • self: Self
Returns
  • Bool
requires_pullback_(mut self, value: Bool = True)
Args
  • self: Self

  • value: Bool (default: True)

requires_grad(self) -> Bool
Args
  • self: Self
Returns
  • Bool
requires_grad_(mut self, value: Bool = True)
Args
  • self: Self

  • value: Bool (default: True)

shape(self) -> List[Int]
Args
  • self: Self
Returns
  • List[Int]
shape_(mut self, shape: List[Int])
Args
  • self: Self

  • shape: List[Int]

dtype(self) -> DType
Args
  • self: Self
Returns
  • DType
batch_dim_ctr(self) -> Int
Args
  • self: Self
Returns
  • Int
batch_dim_ctr_(mut self, value: Int)
Args
  • self: Self

  • value: Int

backward(mut self, remat: Bool = False)
Args
  • self: Self

  • remat: Bool (default: False)

item[type: DType = float32](self, execution_context: Optional[ExecutionContext] = Optional(None)) -> SIMD[type, 1]
Args
  • self: Self

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • SIMD[type, 1]
load[type: DType = float32, width: Int = 1](self, idx: Int, execution_context: Optional[ExecutionContext] = Optional(None)) -> SIMD[type, width]
Args
  • self: Self

  • idx: Int

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • SIMD[type, width]
store[type: DType, width: Int](mut self, idx: Int, value: SIMD[type, width], execution_context: Optional[ExecutionContext] = Optional(None))
Args
  • self: Self

  • idx: Int

  • value: SIMD[type, width]

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

T(self, x: Int = -2, y: Int = -1) -> Self
Args
  • self: Self

  • x: Int (default: -2)

  • y: Int (default: -1)

Returns
  • Self
reshape(self, shape: List[Int]) -> Self
Args
  • self: Self

  • shape: List[Int]

Returns
  • Self

Functions

ones

ones(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

ones_like

ones_like(array: Array, dtype: DType = float32, requires_pullback: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • array: Array

  • dtype: DType (default: float32)

  • requires_pullback: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

full

full(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], fill_value: SIMD[dtype, 1], dtype: DType = $0, requires_pullback: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • fill_value: SIMD[dtype, 1]

  • dtype: DType (default: $0)

  • requires_pullback: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

arange

arange(start: SIMD[float32, 1], end: SIMD[float32, 1], step: SIMD[float32, 1], dtype: DType = float32, requires_pullback: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • start: SIMD[float32, 1]

  • end: SIMD[float32, 1]

  • step: SIMD[float32, 1]

  • dtype: DType (default: float32)

  • requires_pullback: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array
arange(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

zeros

zeros(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

zeros_like

zeros_like(array: Array, dtype: DType = float32, requires_pullback: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None)) -> Array
Args
  • array: Array

  • dtype: DType (default: float32)

  • requires_pullback: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

Returns
  • Array

randn

randn(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None), seed: Optional[Int] = Optional(None), mean: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](0), variance: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](1)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

  • seed: Optional[Int] (default: Optional(None))

  • mean: SIMD[float64, 1] (default: __init__[__mlir_type.!pop.float_literal](0))

  • variance: SIMD[float64, 1] (default: __init__[__mlir_type.!pop.float_literal](1))

Returns
  • Array

rand

rand(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None), seed: Optional[Int] = Optional(None), min: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](0), max: SIMD[float64, 1] = __init__[__mlir_type.!pop.float_literal](1)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

  • seed: Optional[Int] (default: Optional(None))

  • min: SIMD[float64, 1] (default: __init__[__mlir_type.!pop.float_literal](0))

  • max: SIMD[float64, 1] (default: __init__[__mlir_type.!pop.float_literal](1))

Returns
  • Array

he_normal

he_normal(shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]], dtype: DType = float32, requires_grad: Bool = False, execution_context: Optional[ExecutionContext] = Optional(None), seed: Optional[Int] = Optional(None)) -> Array
Args
  • shape: Variant[List[Int], Tuple[Int], Tuple[Int, Int], Tuple[Int, Int, Int], Tuple[Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int], Tuple[Int, Int, Int, Int, Int, Int, Int, Int]]

  • dtype: DType (default: float32)

  • requires_grad: Bool (default: False)

  • execution_context: Optional[ExecutionContext] (default: Optional(None))

  • seed: Optional[Int] (default: Optional(None))

Returns
  • Array
Last updated on
Nabla 2025