将float型转换为long型估计会重新分配内存
import torch
import time
s=torch.rand(9,32,160,160)
b,c,h,w=s.size()
st=time.time()
for i in range(40):
g=s.long()
ed=time.time()
print(ed-st)
不换数据型 1.33514404296875e-05S
换数据型 1.0417239665985107S
耗时应该随数组增大而增大
将float型转换为long型估计会重新分配内存
import torch
import time
s=torch.rand(9,32,160,160)
b,c,h,w=s.size()
st=time.time()
for i in range(40):
g=s.long()
ed=time.time()
print(ed-st)
不换数据型 1.33514404296875e-05S
换数据型 1.0417239665985107S
耗时应该随数组增大而增大