标签:rand oat += ptr and rom 别人 access from
1.error: conversion from ‘at::TensorAccessor<float, 2ul, at::DefaultPtrTraits, long int>’ to non-scalar type ‘at::Tensor’ requested
torch::Tensor result_data = result_.accessor<float,2>();// torch::Tensor result_data = result_.cpu().accessor<float,2>();
定位到代码中的语句
torch::Tensor result_data = result_.accessor<float,2>();
各种试,result是二维的啊,是float的啊!!!
转到了cpu了啊!!
奔溃~~,我看别人也是这么写的啊!!
例子:
torch::Tensor one = torch::randn({9,6});
auto foo_one=one.accessor<float,2>();
for(int i=0,sum=0;i<foo_one.size(0);i++)
for(int j=0;j<foo_one.size(1);j++)
sum+=foo_one[i][j];
然后的然后,我把 torch::Tensor result_data = result_.accessor<float,2>();改成
auto result_data = result_.accessor<float,2>();
编译通过了!!!!ヾ(?`Д′?)!!!!!
这个问题找了我半个小时多!!!!原来已经不是torch::Tensor类型了,需要用auto啊!!
标签:rand oat += ptr and rom 别人 access from
原文地址:https://www.cnblogs.com/yanghailin/p/12876899.html