Solved by yf225 in post #2 
              
              
                vector.data() would convert std::vector to float*, which can be passed into torch::from_blob().

at::ArrayRef shouldn’t make things faster, and auto input_ = torch::from_blob(img.data, {img.rows, img.cols, 3}) should just work.

torch::from_blob() calls tensorFromBlob() internally (https://github.…