Thank you. tensor.clone() can allocate new memory space with new data_ptr, then the old data can be retrieved by garbage collector.
But I wonder if we have more lightweight method — could we do the in-place indexing without (or with less) memory cost? In fact, I think tensor.resize_() is a good way, but it not supports indexing. Also, .clone() may cost some time to clone the tensor.
Thank you for your reply.