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