Could you try to do that instead of your auto f?

at::Tensor f = torch::from_blob(float_buffer, at::IntList(sizes), options);
f = float_buffer.toType(at::kFloat);

also checkout my GitHub repo I did something very similar there in line 31:

  
      github.com
  
  
    tobiascz/MNIST_Pytorch_python_and_capi/blob/master/example-app.cpp 115
#include <iostream>

#include <torch/script.h> // One-stop header.

#include <iostream>
#include <memory>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>


using namespace cv;

void showImage(Mat image)
{
    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow("Display window", image );
    waitKey(0);
}



  This file has been truncated. show original

  
  
    
    
  
  


greetings