I want to deploy the model in C++, but i found the result i got in libtorch is different to pytorch. I can got 90% accuracy in pytorch but 20% in C++. How could lead to the difference?
I just give the model the same data input size. Here is my code for input:

torch::Tensor tensor_image = torch::from_blob(img.data, {  300, 800, 3 }, torch::kByte);
tensor_image = tensor_image.permute({ 2,0,1});
tensor_image = tensor_image.toType(torch::kFloat);
tensor_image = tensor_image.to(device);
torch::Tensor tensor_asc = torch::from_blob(img.data, { 300, 800}, torch::kByte);
tensor_asc = tensor_asc.toType(torch::kFloat);
tensor_asc = tensor_asc.to(device);
cout << “The data has been transformed to tensor\n”;
tensor_asc = torch::unsqueeze(tensor_asc, 0);
torch::Tensor inputs = torch::cat({ tensor_image, tensor_asc }, 0);
inputs = torch::stack({ inputs, inputs }, 0);
inputs = torch::unsqueeze(inputs, 0);

I need to concat two img. and i did the same in python for pytorch. The inference accuracy is 90%.