Native CUDA array to TorchLib Tensor
Published:
A small problem I encountered was how to convert a native CUDA array to a TorchLib Tensor in C++. Some posts such as this give a very good example of doing so, but the “tricky part” of the image step is not clearly stated. According to the OpenCV doc, step means “a distance between successive rows in bytes; includes the gap if any”, so it should be the length of one row in bytes. So in the orginal github issue, long long step = image.step / sizeof(float);
basically means the actual length of the row.