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.
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
actual_index()
@type actual_index() :: nil | boolean() | ExTorch.Index.Slice.t() | integer() | ExTorch.Tensor.t() | :ellipsis
An actual index element, after aliases are interpreted.
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 asnil
false
- Adds a zero dimension on the specified position.
ellipsis_index()
@type ellipsis_index() :: :ellipsis | :...
Skip dimensions in between other ones.
Notes
Ellipsis indices will behave as a sequence of empty
ExTorch.Index.Slice
s 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])
index()
@type index() :: dim_modifier_index() | range_index() | tensor_list_index() | ellipsis_index() | integer_index()
An individual index element.
integer_index()
@type integer_index() :: integer()
Access a tensor given a particular integer index.
integer_list()
@type integer_list() :: integer_index() | [integer_list()]
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 onend
, as opposed to its usual behaviour in Elixir.Slice.t()
- SeeExTorch.Index.Slice
:::
- Same as invokingExTorch.slice/0
.
A complete possible index. It can be either a puntual index or a list of puntual indices.
tensor_list_index()
@type tensor_list_index() :: ExTorch.Tensor.t() | integer_list()
Access a tensor given another tensor or a list of integers.