you can reference here :
auto img_tensor = torch::CUDA(torch::kFloat32).tensorFromBlob(img_float.data, {1, 224, 224, 3});
img_tensor = img_tensor.permute({0, 3, 1, 2});

https://github.com/pytorch/pytorch/issues/14219 29