Tensor, strides, and storage: why a transpose can be freeTensor、步幅与存储:转置为什么可以不搬数据
For a dense strided tensor, strides and storage_offset map logical indices to storage locations. Transpose shares the original storage by swapping sizes and strides; making a noncontiguous result contiguous requires copying its data.对稠密步幅张量,strides 与 storage_offset 决定逻辑索引对应的存储位置。转置通过交换形状和步幅共享原存储;将非连续结果转为连续布局则需要复制数据。