×

签到

分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

torch.cosine_similarity 使用报错 已解决 shimin.an2023-01-16 10:52:49 回复 5 查看 使用求助
torch.cosine_similarity 使用报错
分享到:

【寒武纪硬件产品型号】必填*:
必填项,例如:MLU270


【使用操作系统】必填*:
官网提供的pytorch docker:ubuntu18.04_sdk_v1.7.0_pytorch_v0.15.0-2


【使用驱动版本】必填*:
例如v4.9.4


【出错信息】必填*:

[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:2396][clamp_min_][thread:140100531672896][process:228452]:
clamp_min_ Op cannot run on MLU device, start running on CPU!
【当前已做了哪些信息确认】选填:

1. >>> import torch
>>> import torch_mlu.core.mlu_model as ct
CNML: 7.10.2 ba2048758
CNRT: 4.10.1 a884a9a
>>> a=torch.rand(10,1,5,dtype=torch.float).to(ct.mlu_device())
>>> b=torch.rand(1,5,5,dtype=torch.float).to(ct.mlu_device())
>>> cos=torch.cosine_similarity(a,b,dim=-1,eps=1e-08).to(ct.mlu_device())
[WARNING][/pytorch/catch/torch_mlu/csrc/aten/operators/op_methods.cpp][line:2396][clamp_min_][thread:139818913498944][process:228735]:
clamp_min_ Op cannot run on MLU device, start running on CPU!

2.CNML Developer Guide Release 7.10.2

4.36.1 cnmlCreateCosSimilarityOp
cnmlStatus_t cnmlCreateCosSimilarityOp(cnml Op_t *op, const cnmlTensor_t inputTensorA, const cnmlTensor_t inputTensorB,
const cnmlTensor_t outputTensor)
cnmlCreateCosSimilarityOp.
It creates a cos similarity operator d on the operator pointer given by the user.

看了CNML文档可以支持余弦相似性函数

2.查看/usr/local/neuware/include/cnml.h,版本号如下,其中也看到cnmlCreateCosSimilarityOp

#define CNML_MAJOR_VERSION 7
#define CNML_MINOR_VERSION 10
#define CNML_PATCH_VERSION 2

问题1、clamp_min_ Op cannot run on MLU device, start running on CPU!  这个怎么解决?是否需要升级版本?

问题2、保存多输入离线模型时:

net = torch.jit.trace(quantized_model, (input_data1, input_data2), check_trace = False)
net(input_data1, input_data2)

离线模型输入会变成一个,2个3维输入变成一个4维输入,是否保存方式有误?




版权所有 © 2022 寒武纪 Cambricon.com 备案/许可证号:京ICP备17003415号-1
关闭