def genoff(model, mname, batch_size, core_number, in_heigth, in_width, half_input, input_format, fake_device, quantized_mode): genoff 函数的定义和使用也要把 quantized_mode 加进去展开
自己来回答一波,从conv2d_first的定义来看:Tensor _7, Tensor _8, Tensor _9, Tensor _10 分别对应scale, mode, mean, std。在生成resnet50离线模型的时候,缺少mode的信息。genoff.py中虽然有quantized_mode 的选项,但是这个选项不起任何作用。需要在genoff.py中添加如下代码[代码]展开
自己来回答一波,从conv2d_first的定义来看:Tensor _7, Tensor _8, Tensor _9, Tensor _10 分别对应scale, mode, mean, std。在生成resnet50离线模型的时候,缺少mode的信息。genoff.py中虽然有quantized_mode 的选项,但是这个选项不起任何作用。需要在genoff.py中添加如下代码
import torch_mlu.core.quantized as cq ... net = net.eval().float() # ---------------- add --------------- for m in net.modules(): if isinstance(m, (cq.MLUConv1d, cq.MLUConv2d, cq.MLULinear)): m.set_quantized_mode(torch.tensor(quantized_mode)) # ------------------------------------ # prepare input example_mlu = torch.randn(batch_size, 3, in_h, in_w, dtype=torch.float) ...
将Cambricon-MLU270-models-pytorch.tar中的resnet50-19c8e357.pth放到对应位置。再次执行
python pytorch/tools/genoff.py -model resnet50 -mname test -mcore MLU270 -core_number 1 -batch_size 1 -half_input 1
还是出错,错误信息
RuntimeError: torch_mlu::conv2d_first() Expected a value of type 'Tensor' for argument '_8' but instead found type 'NoneType'.
Position: 8
Value: None
Declaration: torch_mlu::conv2d_first(Tensor _0, Tensor _1, Tensor _2, int[] _3, int[] _4, int[] _5, int _6, Tensor _7, Tensor _8, Tensor _9, Tensor _10) -> (Tensor _0)
请登录后评论