“tensorFromBlob”: 不是“at::DeprecatedTypeProperties”的成员

“tensorFromBlob”: 不是“at::DeprecatedTypeProperties”的成员

错误代码:

auto img_tensor = torch::CPU(torch::kFloat32).tensorFromBlob(img_float.data, { 1, input_image_size, input_image_size, 3 });

原因: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);

 

 

bn_running_var = bn_running_var.view_as(bn_imp->running_var);// ->running_variance);

 

bn_imp->running_variance.set_data(bn_running_var);

改之后:

bn_imp->running_var.set_data(bn_running_var);

你可能感兴趣的:(c++,torch)