Add tile
and repeat_values
procedures
#648
Merged
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.
Add the following new procedures:
repeat_values
: Procedures that let you repeat the values of a Tensor multiple times. This functionality exists both in numpy (repeat
) and in Matlab (repelem
).tile
: Procedure that lets you construct a new tensor by repeating the input tensor a number of times on one or more axes. This functionality exists both in numpy (tile
) and in Matlab (repmat
).I didn't follow numpy's naming convention for
repeat_values
to avoid a confusing with nim'ssequtils.repeat
, which does not repeat individual values but the whole sequence (liketile
does).I measured the performance of these functions and it is comparable to numpy's.
repeat_values
is faster than numpy in --d:danger mode and a bit slower in --d:release mode.tile
is slower in both cases (but the difference is not too large).tile
's implementation could be improved (to avoid intermediate tensor allocations) in the future.