使用Pyorch出现“tensorFromBlob”: 不是“at::DeprecatedTypeProperties”的成员
编译时报错:
原因:libtorch 1.1的接口改了,
正确代码:
auto img_tensor = torch::from_blob(image.data, {1, inp_dim[0], inp_dim[1], 3}).permute({0, 3, 1, 2}).to(torch::kCUDA);
旧版代码:
auto img_tensor = torch::CPU(torch::kFloat32).tensorFromBlob(img_float.data, { 1, input_image_size, input_image_size, 3 });
img_tensor = img_tensor.permute({ 0,3,1,2 });
auto img_var = torch::autograd::make_variable(img_tensor, false).to(device);
新版代码:
auto img_tensor = torch::from_blob(image.data, {1, inp_dim[0], inp_dim[1], 3}).permute({0, 3, 1, 2}).to(torch::kCUDA);