打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
【寒武纪硬件产品型号】必填*:MLU270
我们尝试在将ppyoloe项目移植到寒武纪上,在将模型和图片输入转换为(MLU).to(ct.mlu_device())后无法在以下函数中将tensor进行强制类型转换,想将class_pred变量转换为float但是操作失败;
def my_multiclass_nms(bboxes, scores, score_threshold=0.7, nms_threshold=0.45, nms_top_k=1000, keep_top_k=100, class_agnostic=False): # 每张图片的预测结果 output = [None for _ in range(len(bboxes))] # 每张图片分开遍历 for i, (xyxy, score) in enumerate(zip(bboxes, scores)): # 每个预测框最高得分的分数和对应的类别id class_conf, class_pred = torch.max(score, 1, keepdim=True) print(class_pred.float().dtype) # 分数超过阈值的预测框为True conf_mask = (class_conf.squeeze() >= score_threshold).squeeze() # 这样排序 (x1, y1, x2, y2, 得分, 类别id) detections = torch.cat((xyxy, class_conf, class_pred.float()), 1) # 只保留超过阈值的预测框
torch.int32 [ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/copy.cpp][line:36][cast_type][thread:140096729085760][process:3264647]: You are trying to convert Int tensor to Float tensor! We do not support this kind of type cast! [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:68][copy_][thread:140096729085760][process:3264647]: copy_ Op cannot run on MLU device, start running on CPU! [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:71][copy_][thread:140096729085760][process:3264647]: Not really copying data from MLU to MLU! Two MLU tensor will share same storage space! torch.int32 [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:2037][ge][thread:140096729085760][process:3264647]: ge Op cannot run on MLU device, start running on CPU! [ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/copy.cpp][line:36][cast_type][thread:140096729085760][process:3264647]: You are trying to convert Int tensor to Float tensor! We do not support this kind of type cast! [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:68][copy_][thread:140096729085760][process:3264647]: copy_ Op cannot run on MLU device, start running on CPU! [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:71][copy_][thread:140096729085760][process:3264647]: Not really copying data from MLU to MLU! Two MLU tensor will share same storage space! [ERROR][/pytorch/catch/torch_mlu/csrc/aten/operators/cnml/concat.cpp][line:18][cnml_cat][thread:140096729085760][process:3264647]: Mixture dtype computation not support float and int Currently only support: float c10::Half [WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:2289][cat][thread:140096729085760][process:3264647]: cat Op cannot run on MLU device, start running on CPU! Traceback (most recent call last): File "mlu_qua_foward.py", line 274, in <module> main(exp, args) File "mlu_qua_foward.py", line 262, in main image_demo(predictor, vis_folder, args.path, current_time, args.save_result) File "mlu_qua_foward.py", line 164, in image_demo outputs, img_info = predictor.inference(image_name) File "mlu_qua_foward.py", line 128, in inference outputs = self.model(img, scale_factor) File "/torch/venv3/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__ result = self.forward(*input, **kwargs) File "/workdir/miemiedetection-main/mmdet/models/architectures/ppyoloe.py", line 36, in forward out = self.yolo_head.post_process(out, scale_factor) File "/workdir/miemiedetection-main/mmdet/models/heads/ppyoloe_head.py", line 595, in post_process preds = my_multiclass_nms(pred_bboxes, yolo_scores, **nms_cfg) File "/workdir/miemiedetection-main/mmdet/utils/boxes.py", line 106, in my_multiclass_nms detections = torch.cat((xyxy, class_conf, class_pred.float()), 1) RuntimeError: Expected object of scalar type Float but got scalar type Int for sequence element 2 in sequence argument at position #1 'tensors' (pytorch) root@ubuntu:/workdir/miemiedetection-main# RuntimeError: Expected object of scalar type Float but got scalar type Int for sequence element 2 in sequence argument at position #1 'tensors'
【使用操作系统】必填*:ubuntu
【使用驱动版本】必填*:v4.20.6
例如:v4.20.6
【使用AI框架】必填*:Pytorch
例如:Pytorch,
【操作步骤】选填:
【出错信息】必填*:
【当前已做了哪些信息确认】选填:
例如:交叉验证/CPU能运行/调试通过等
【参考配置文档链接】选填
【相关日志文档】选填
如有,可附件
【出错代码链接】选填:
github的或gitee的代码的链接,
https://github.com/miemie2013/miemiedetection
热门帖子
精华帖子