10 #ifdef MOOSE_LIBTORCH_ENABLED 14 #include <torch/torch.h> 27 template <
typename DataType>
29 torch::Tensor & tensor,
30 const bool detach =
false);
38 template <
typename DataType>
39 torch::Tensor
vectorToTensorCopy(
const std::vector<DataType> & vector, c10::IntArrayRef sizes);
49 template <
typename DataType>
50 torch::Tensor
vectorToTensorView(std::vector<DataType> & vector, c10::IntArrayRef sizes);
76 template <
typename DataType>
77 void tensorToVector(torch::Tensor & tensor, std::vector<DataType> & vector);
torch::Tensor vectorToTensorView(std::vector< DataType > &vector, c10::IntArrayRef sizes)
Utility function that creates a non-owning tensor view of a standard vector.
torch::Tensor vectorToTensorCopy(const std::vector< DataType > &vector, c10::IntArrayRef sizes)
Utility function that creates an owning tensor copy of a standard vector.
void tensorToVector(torch::Tensor &tensor, std::vector< DataType > &vector)
Utility function that converts a torch::Tensor to a standard vector.
torch::Tensor toCPUContiguous(const torch::Tensor &tensor)
Return a detached contiguous CPU copy of a tensor.
void vectorToTensor(const std::vector< DataType > &vector, torch::Tensor &tensor, const bool detach=false)
Utility function that converts a standard vector to a torch::Tensor.
void moveToLibtorchDevice(torch::Tensor &tensor, const torch::DeviceType device_type)
Move a tensor to the configured libtorch device.