Type check accessors []
, []=
and add index_select
for multiple values
#653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This finally makes the
[]
,[]=
mostly "type safe". Just handing in any type and falling back to the compile time errors of the (mostly internal) procedures likeindex_select
is a thing of the past now. If the argument is not allowed, we simply throw a (better) error message telling the user that the type is not valid.On Nim devel we can also type check
Tensor[T]
(i.e. the inner type), because nowadays doingworks as expected. Nim issue #14021 nim-lang/Nim#14021 should in principle be fixed on devel (but not 2.0.4). Haven't check the Nim issue fully yet though.
This also adds support to not only index a tensor at multiple indices, but also assign multiple at the same time:
are all valid now. Previously we could only read with multiple indices.
Note that multi dimensional slicing of arbitrary indices is still not supported.