微凉的衣柜 2021-06-03 00:16 采纳率: 64.7%
浏览 292
已采纳

(Libtorch) FP16 tensor 错误 C10error

I got c10 error when I define a FP16 tensor and use torch::max() and torch::sqrt(). The code are shown as follows:

当我定义一个FP16的tensor并使用torch::max() 和 torch::sqrt()函数时会出现C10 error错误,代码如下:

	float test_float[3][3] = { {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0 },{7.0, 8.0, 9.0} };
	torch::Tensor test_float_tensor = torch::from_blob(test_float, { 3, 3 }).to(at::kCPU).to(torch::kFloat16);
	torch::sqrt(test_float_tensor);
	torch::max(test_float_tensor, 1, true);

错误如下:

当把tensor改为FP32或FP64,错误就消失了,代码如下:

	float test_float[3][3] = { {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0 },{7.0, 8.0, 9.0} };
	torch::Tensor test_float_tensor = torch::from_blob(test_float, { 3, 3 }).to(at::kCPU).to(torch::kFloat32);
	torch::sqrt(test_float_tensor);
	torch::max(test_float_tensor, 1, true);

为什么会造成这种错误呢?采用FP16 tensor,执行torch::sum()函数时并不会出现这个错误。是FP16 tensor有什么不适用的地方吗?求解答,谢谢!

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?