-Global Context Settings
+Global Context Settings
These are global routines which affect the behavior of the libtorch backend. It is therefore recommended to call these functions before any other TorchFort calls are made.
-torchfort_set_cudnn_benchmark
+torchfort_set_cudnn_benchmark
-
torchfort_result_t torchfort_set_cudnn_benchmark(const bool flag)
@@ -235,20 +311,21 @@ Global Context Settings
-Supervised Learning
+Supervised Learning
-Model Creation
+Model Creation
-torchfort_create_model
+torchfort_create_model
--
-torchfort_result_t torchfort_create_model(const char *name, const char *config_fname)
+-
+torchfort_result_t torchfort_create_model(const char *name, const char *config_fname, int device)
Creates a model instance from a provided configuration file.
- Parameters
name – [in] A name to assign to the created model instance to use as a key for other TorchFort routines.
-config_fname – [in] The filesystem path to the user-defined model configuration file to use.
+config_fname – [in] The filesystem path to the user-defined model configuration file to use.
+device – [in] Which device to place and run the model on. For TORCHFORT_DEVICE_CPU (-1), model will be placed on CPU. For values >= 0, model will be placed on GPU with index corresponding to value.
- Returns
@@ -260,17 +337,18 @@ Model Creation
-torchfort_create_distributed_model
+torchfort_create_distributed_model
--
-torchfort_result_t torchfort_create_distributed_model(const char *name, const char *config_fname, MPI_Comm mpi_comm)
+-
+torchfort_result_t torchfort_create_distributed_model(const char *name, const char *config_fname, MPI_Comm mpi_comm, int device)
Creates a distributed data-parallel model from a provided configuration file.
- Parameters
name – [in] A name to assign to created model to use as a key for other TorchFort routines.
config_fname – [in] The filesystem path to the user-defined model configuration file to use.
-mpi_comm – [in] MPI communicator to use to initialize NCCL communication library for data-parallel communication.
+mpi_comm – [in] MPI communicator to use to initialize NCCL communication library for data-parallel communication.
+device – [in] Which device to place and run the model on. For TORCHFORT_DEVICE_CPU (-1), model will be placed on CPU. For values >= 0, model will be placed on GPU with index corresponding to value.
- Returns
@@ -283,9 +361,9 @@ Model Creation
-Model Training/Inference
+Model Training/Inference
-torchfort_train
+torchfort_train
-
torchfort_result_t torchfort_train(const char *name, void *input, size_t input_dim, int64_t *input_shape, void *label, size_t label_dim, int64_t *label_shape, void *loss_val, torchfort_datatype_t dtype, cudaStream_t stream)
@@ -302,7 +380,7 @@ Model Training/Inference
-torchfort_inference
+torchfort_inference
-
torchfort_result_t torchfort_inference(const char *name, void *input, size_t input_dim, int64_t *input_shape, void *output, size_t output_dim, int64_t *output_shape, torchfort_datatype_t dtype, cudaStream_t stream)
@@ -330,7 +408,7 @@ Model Training/Inference