Thanks for your reply Kushaj,
I’ve attempted your suggestion but it doesn’t solve the issue, although I’m not sure what you meant by “adding the result to the original tensors”.
torch::Tensor prediction = net->forward(img_tensor);

// create a new instance of the tensor by detaching the original tensor 
torch::Tensor prediction_cpy = prediction.detach();

cv::Mat prediction_vectors(cv::Size(512, 512), CV_32FC3, prediction_cpy.data_ptr());

// some image processing magic 
cv::Mat someOutput = someImageProcessingMagic;  

// do you mean add?
prediction.add(torch::from_blob(someOutput.data, { 1, 3, 512, 512 }));

torch::Tensor loss = torch::mse_loss(prediction, target);


Thanks again for your help.