For loss computing (for a convolutional model) i am trying to convert my data which is stored in a 4D-std::vector of type double to a torch::Tensor using torch::from_blob.
i am using the Gramian Angular Field to convert timeseries to an image. My code looks like this:
std::vector<std::vector<std::vector<std::vector<double>>>> resallGAF(32);
// Compute GAF batch
for(unsigned int i = 0; i < batchSize; i++)
{
// Creating data here
}
torch::Tensor result = torch::from_blob(resallGAF.data(), {static_cast<long>(resallGAF.size()), static_cast<long>(resallGAF[0].size()), static_cast<long>(resallGAF[0][0].size()), static_cast<long>(resallGAF[0][0][0].size())} ).clone();
When .clone() is called. i get a exc_bad_access error from xcode. (SIGSEV) resallGAF has the shape {32, 4, 150, 150}
.
When i use similar code to convert vector of shape {1, 4, 32, 32}
to a Tensor everything works fine. I cannot print or forward the resulting Tensor either, when removing the .clone()
.
I checked the data and the shapes and data are normally valid.
I tired it with libtorch 1.3.1 and 1.4.0 both without CUDA support.
Thanks in advance