Docs
View Ops

View Operations

View operations create a new view of an existing array without copying the data.

array_slice

def array_slice(arg0: Array, slices: List[Slice]) -> Array
Slices the input array based on the given slices.
Args

arg0: The input array. slices: The slices to apply.

Returns

The sliced array.

detach

def detach(arg0: Array) -> Array
Detaches the input array from the computation graph.
Args

arg0: The input array.

Returns

The detached array.

Note

This function is non-differentiable.

expand

def expand(arg0: Array, shape: ArrayShape, ignore_axes: List[Int] = List[Int]()) -> Array
Expands the input array to the given shape.
Args

arg0: The input array. shape: The target shape. ignore_axes: The axes to ignore during expansion.

Returns

The expanded array.

expand_as

def expand_as(arg0: Array, arg1: Array) -> Array
Expands the input array to the shape of the target array.
Args

arg0: The input array. arg1: The target array.

Returns

A view on the input array with the shape of the target array.

Note

This function is a wrapper around the expand function with the target shape being the shape of the target array.

broadcast_to

def broadcast_to(arg0: Array, shape: List[Int]) -> Array
Broadcasts the input array to the given shape.
Args

arg0: The input array. shape: The target shape.

Returns

A view on the input array with the target shape.

Note

This function is a wrapper around the expand function with the target shape being the shape of the target array.

imag

def imag(arg0: Array) -> Array
Computes the imaginary part of the input array.
Args

arg0: The input array.

Returns

An array containing the imaginary part of the input array.

Note

This function supports:

  • Complex input arrays.
  • Non-differentiable operation.

as_strided_inv

def as_strided_inv(arg0: Array, target_shape: ArrayShape, shape: List[Int], stride: List[Int], storage_offset: Int) -> Array
Creates a view of the input array with the given shape and stride.
Args

arg0: The input array. target_shape: The target shape of the view. shape: The shape of the view. stride: The stride of the view. storage_offset: The storage offset of the view.

Returns

A view of the input array with the given shape and stride.

pad

def pad(arg0: Array, target_shape: ArrayShape, slices_in_target: List[Slice]) -> Array
Pads an array to a target shape.
Args

arg0: The input array to be padded. target_shape: The target shape to pad the input array to. slices_in_target: A list of slices specifying the region in the target shape where the input array is copied.

Returns

An array containing the input array padded to the target shape.

Note

This function supports:

  • Automatic differentiation (reverse mode only).
  • Complex valued arguments.

permute

def permute(arg0: Array, axis: ArrayShape) -> Array
Creates a view of the input array with its dimensions permuted based on the given axis.
Args

arg0: The input array. axis: The axis to permute.

Returns

A view of the input array with its dimensions permuted.

Note

This function supports:

  • Automatic differentiation (forward and reverse modes).
  • Complex valued arguments.

transpose

def transpose(arg0: Array, axis1: Int, axis2: Int) -> Array
Transposes the input array based on the given axes.
Args

arg0: The input array. axis1: The first axis to transpose. axis2: The second axis to transpose.

Returns

The transposed array.

Note

This function is a wrapper around the permute function with the given axes.

swapaxes

def swapaxes(arg0: Array, axis1: Int, axis2: Int) -> Array
Swaps the input array's axes based on the given axes.
Args

arg0: The input array. axis1: The first axis to swap. axis2: The second axis to swap.

Returns

The array with the axes swapped.

Note

This function is a wrapper around the transpose function with the given axes.

swapdims

def swapdims(arg0: Array, axis1: Int, axis2: Int) -> Array
Swaps the input array's dimensions based on the given axes.
Args

arg0: The input array. axis1: The first axis to swap. axis2: The second axis to swap.

Returns

The array with the dimensions swapped.

Note

This function is a wrapper around the transpose function with the given axes.

real

def real(arg0: Array) -> Array
Computes the real part of the input array element-wise.
Args

arg0: The input array.

Returns

The real part of the input array.

squeeze

def squeeze(arg0: Array) -> Array
Squeezes the input array by removing axes of length 1.
Args

arg0: The input array.

Returns

The squeezed array.

unsqueeze

def unsqueeze(arg0: Array, axis: ArrayShape) -> Array
Unsqueezes the input array by adding axes of length 1.
Args

arg0: The input array. axis: The axis to unsqueeze.

Returns

The unsqueezed array.

view_as_imag

def view_as_imag(arg0: Array) -> Array
Creates a view of the input array as an imaginary array.
Args

arg0: The input array.

Returns

A view of the input array as an imaginary array.

Note

This function is non-differentiable.

view_as_real

def view_as_real(arg0: Array) -> Array
Creates a view of the input array as the real part of a complex array.
Args

arg0: The input array.

Returns

A view of the input array as the real part of a complex array.