Skip to content

How to slice a tensor without copying it? #2449

Answered by laggui
InAnYan asked this question in Q&A
Discussion options

You must be logged in to vote

If you still want to use the tensor after the slice, simply do tensor.clone().slice(...). Cloning does not copy the data it just increases a reference count. And then you can proceed to use tensor in following operations.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@InAnYan
Comment options

Answer selected by InAnYan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants