Thank you. In fact I just operate on a tensor without grad record.
But I find that resize_ can only crop the consecutive memory region … In practice, I do some operations in a spatial-temporal tensor (B x C x T x H x W) in video models, and I want to do in-place indexing in T dimension. However, T dimension is not consecutive in memory thus resize_ produces wrong results.
Now I just use .clone(), although it costs more memory.