ExTorch.Index (extorch v0.1.0-pre0)

An index is an object that can act as an accessor to a ExTorch.Tensor. ExTorch has five kinds of indices:

Link to this section Summary

Types

An actual index element, after aliases are interpreted.

Dimension appending/removing indices.

Skip dimensions in between other ones.

An individual index element.

Access a tensor given a particular integer index.

Access a slice of elements in the tensor given a range.

t()

A complete possible index. It can be either a puntual index or a list of puntual indices.

Access a tensor given another tensor or a list of integers.

Link to this section Types

Link to this type

actual_index()

@type actual_index() ::
  nil
  | boolean()
  | ExTorch.Index.Slice.t()
  | integer()
  | ExTorch.Tensor.t()
  | :ellipsis

An actual index element, after aliases are interpreted.

Link to this type

dim_modifier_index()

@type dim_modifier_index() :: nil | boolean()

Dimension appending/removing indices.

description

Description

  • nil - Adds an empty dimension on the specified position.
  • true - Same as nil
  • false - Adds a zero dimension on the specified position.
Link to this type

ellipsis_index()

@type ellipsis_index() :: :ellipsis | :...

Skip dimensions in between other ones.

Notes

Ellipsis indices will behave as a sequence of empty ExTorch.Index.Slices between the dimensions that are specified. e.g.,

a = ExTorch.empty({3, 4, 5, 6})

# Indexing will yield a tensor of size {4, 5}
indexing = ExTorch.index(a, [0, :..., 1])

An individual index element.

Link to this type

integer_index()

@type integer_index() :: integer()

Access a tensor given a particular integer index.

Link to this type

integer_list()

@type integer_list() :: integer_index() | [integer_list()]
Link to this type

range_index()

@type range_index() :: Range.t() | ExTorch.Index.Slice.t() | :"::"

Access a slice of elements in the tensor given a range.

description

Description

  • start..end//step - A standard Elixir range struct, it will be non-inclusive on end, as opposed to its usual behaviour in Elixir.
  • Slice.t() - See ExTorch.Index.Slice
  • ::: - Same as invoking ExTorch.slice/0.
@type t() :: index() | [index()] | tuple()

A complete possible index. It can be either a puntual index or a list of puntual indices.

Link to this type

tensor_list_index()

@type tensor_list_index() :: ExTorch.Tensor.t() | integer_list()

Access a tensor given another tensor or a list of integers.