你好,CNML手册中对tensor输入描述如下:[in] input_tensor: Input. A 4‑dimensional MLU input tensor, the shape is [ni, ci, hi, wi] 你目前的输入,与MLU tensor要求不符合,可以扩充维度,如:xyz = torch.randn((4,1024,3,5),dtype=torch.float)或者就是参考上面回复的代码,在CPU中进行切片处理。展开
你好,你这样切片操作,涉及到一个变量在MLU还是CPU的问题。请参考下面的代码:
xyz = torch.randn((4,1024,3),dtype=torch.float)
xyz_mlu = xyz.to(ct.mlu_device())
tmp = xyz[0,10,:]
print("CPU")
print(type(tmp))
# 正常
print(tmp.cpu())
a = tmp[0]
# 正常
print(a.cpu())
# 正常
b = tmp[1]
print(b.cpu())
print("MLU")
c = xyz_mlu[0,10,:]
print(c.cpu())
d = tmp[1]
print(d.cpu())
你好!请贴出你的测试代码,方便排查问题。
这是具体测试代码
import torch import torch.nn as nn from torch.autograd import Variable import torch_mlu import torch_mlu import torch_mlu.core.mlu_model as ct torch.set_grad_enabled(False) torch.manual_seed(10) ct.set_core_number(16) ct.set_core_version('MLU270') xyz = torch.randn((4,1024,3),dtype=torch.float).to(ct.mlu_device()) tmp = xyz[0,10,:] # 正常 print(tmp.cpu()) a = tmp[0] # 正常 print(a.cpu()) b = tmp[1] # 报错 print(b.cpu())
这里是报错情况
请登录后评论