(git:691081d)
Loading...
Searching...
No Matches
torch_api Module Reference

Data Types

type  torch_tensor_type
type  torch_dict_type
type  torch_model_type
interface  torch_tensor_from_array
interface  torch_tensor_reset_from_array
interface  torch_tensor_data_ptr
interface  torch_model_get_attr

Functions/Subroutines

subroutine, public torch_tensor_expand_dim (tensor, dim, extent, result)
 Creates an expanded tensor view along one singleton dimension.
subroutine, public torch_tensor_narrow (tensor, dim, start_index, length, result)
 Creates a view of a contiguous tensor slice.
subroutine, public torch_tensor_backward (tensor, outer_grad)
 Runs autograd on a Torch tensor.
subroutine, public torch_tensor_backward_scalar (tensor)
 Runs autograd on a scalar Torch tensor.
subroutine, public torch_tensor_to_device_leaf (tensor, requires_grad)
 Moves a tensor to the active Torch device and makes it an autograd leaf.
subroutine, public torch_use_cuda (use_cuda)
 Select whether Torch wrappers should use CUDA when available.
subroutine, public torch_tensor_grad (tensor, grad)
 Returns the gradient of a Torch tensor which was computed by autograd.
subroutine, public torch_tensor_grad_batch3 (tensor1, tensor2, tensor3, grad1, grad2, grad3)
 Copies three autograd gradients to CPU memory.
subroutine, public torch_tensor_weighted_sum (values, weights, result)
 Returns the weighted sum of two Torch tensors.
real(kind=dp) function, public torch_tensor_item_double (tensor)
 Returns a scalar double value from a Torch tensor.
subroutine, public torch_tensor_release (tensor)
 Releases a Torch tensor and all its ressources.
subroutine, public torch_dict_create (dict)
 Creates an empty Torch dictionary.
subroutine, public torch_dict_clone (source, target)
 Clones a Torch dictionary.
subroutine, public torch_dict_insert (dict, key, tensor)
 Inserts a Torch tensor into a Torch dictionary.
subroutine, public torch_dict_get (dict, key, tensor)
 Retrieves a Torch tensor from a Torch dictionary.
subroutine, public torch_dict_release (dict)
 Releases a Torch dictionary and all its ressources.
subroutine, public torch_model_load (model, filename)
 Loads a Torch model from given "*.pth" file. (In Torch lingo models are called modules).
subroutine, public torch_model_load_with_metadata (model, filename, key1, value1, key2, value2)
 Loads a Torch model and reads two metadata entries in the same archive pass.
subroutine, public torch_model_remap_device_constants (model)
 Maps serialized TorchScript device constants to the active Torch device.
subroutine, public torch_model_disable_parameter_gradients (model)
 Disable gradients for inference-only model parameters.
subroutine, public torch_model_forward (model, inputs, outputs)
 Evaluates the given Torch model.
subroutine, public torch_model_forward_mol_tensor (model, method_name, inputs, output)
 Evaluates a TorchScript model method expecting keyword argument "mol".
subroutine, public torch_model_release (model)
 Releases a Torch model and all its ressources.
character(:) function, allocatable, public torch_model_read_metadata (filename, key)
 Reads metadata entry from given "*.pth" file. (In Torch lingo they are called extra files).
logical function, public torch_cuda_is_available ()
 Returns true iff the Torch CUDA backend is available.
integer function, public torch_cuda_device_count ()
 Return the number of CUDA devices visible to Torch.
subroutine, public torch_allow_tf32 (allow_tf32)
 Set whether to allow the use of TF32. Needed due to changes in defaults from pytorch 1.7 to 1.11 to >=1.12 See https://pytorch.org/docs/stable/notes/cuda.html.
subroutine, public torch_model_freeze (model)
 Freeze the given Torch model: applies generic optimization that speed up model. See https://pytorch.org/docs/stable/generated/torch.jit.freeze.html.
subroutine, public torch_model_freeze_preserving_method (model, method_name)
 Freeze a Torch model while preserving one exported method.

Function/Subroutine Documentation

◆ torch_tensor_expand_dim()

subroutine, public torch_api::torch_tensor_expand_dim ( type(torch_tensor_type), intent(in) tensor,
integer, intent(in) dim,
integer, intent(in) extent,
type(torch_tensor_type), intent(inout) result )

Creates an expanded tensor view along one singleton dimension.

Definition at line 1392 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_narrow()

subroutine, public torch_api::torch_tensor_narrow ( type(torch_tensor_type), intent(in) tensor,
integer, intent(in) dim,
integer, intent(in) start_index,
integer, intent(in) length,
type(torch_tensor_type), intent(inout) result )

Creates a view of a contiguous tensor slice.

Definition at line 1429 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_backward()

subroutine, public torch_api::torch_tensor_backward ( type(torch_tensor_type), intent(in) tensor,
type(torch_tensor_type), intent(in) outer_grad )

Runs autograd on a Torch tensor.

Author
Ole Schuett

Definition at line 1470 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_backward_scalar()

subroutine, public torch_api::torch_tensor_backward_scalar ( type(torch_tensor_type), intent(in) tensor)

Runs autograd on a scalar Torch tensor.

Definition at line 1502 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_to_device_leaf()

subroutine, public torch_api::torch_tensor_to_device_leaf ( type(torch_tensor_type), intent(inout) tensor,
logical, intent(in) requires_grad )

Moves a tensor to the active Torch device and makes it an autograd leaf.

Definition at line 1525 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_use_cuda()

subroutine, public torch_api::torch_use_cuda ( logical, intent(in) use_cuda)

Select whether Torch wrappers should use CUDA when available.

Definition at line 1553 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_grad()

subroutine, public torch_api::torch_tensor_grad ( type(torch_tensor_type), intent(in) tensor,
type(torch_tensor_type), intent(inout) grad )

Returns the gradient of a Torch tensor which was computed by autograd.

Author
Ole Schuett

Definition at line 1574 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_grad_batch3()

subroutine, public torch_api::torch_tensor_grad_batch3 ( type(torch_tensor_type), intent(in) tensor1,
type(torch_tensor_type), intent(in) tensor2,
type(torch_tensor_type), intent(in) tensor3,
type(torch_tensor_type), intent(inout) grad1,
type(torch_tensor_type), intent(inout) grad2,
type(torch_tensor_type), intent(inout) grad3 )

Copies three autograd gradients to CPU memory.

Definition at line 1602 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_weighted_sum()

subroutine, public torch_api::torch_tensor_weighted_sum ( type(torch_tensor_type), intent(in) values,
type(torch_tensor_type), intent(in) weights,
type(torch_tensor_type), intent(inout) result )

Returns the weighted sum of two Torch tensors.

Definition at line 1642 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_item_double()

real(kind=dp) function, public torch_api::torch_tensor_item_double ( type(torch_tensor_type), intent(in) tensor)

Returns a scalar double value from a Torch tensor.

Definition at line 1673 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_tensor_release()

subroutine, public torch_api::torch_tensor_release ( type(torch_tensor_type), intent(inout) tensor)

Releases a Torch tensor and all its ressources.

Author
Ole Schuett

Definition at line 1700 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_dict_create()

subroutine, public torch_api::torch_dict_create ( type(torch_dict_type), intent(inout) dict)

Creates an empty Torch dictionary.

Author
Ole Schuett

Definition at line 1724 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_dict_clone()

subroutine, public torch_api::torch_dict_clone ( type(torch_dict_type), intent(in) source,
type(torch_dict_type), intent(inout) target )

Clones a Torch dictionary.

Definition at line 1747 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_dict_insert()

subroutine, public torch_api::torch_dict_insert ( type(torch_dict_type), intent(inout) dict,
character(len=*), intent(in) key,
type(torch_tensor_type), intent(in) tensor )

Inserts a Torch tensor into a Torch dictionary.

Author
Ole Schuett

Definition at line 1775 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_dict_get()

subroutine, public torch_api::torch_dict_get ( type(torch_dict_type), intent(in) dict,
character(len=*), intent(in) key,
type(torch_tensor_type), intent(inout) tensor )

Retrieves a Torch tensor from a Torch dictionary.

Author
Ole Schuett

Definition at line 1807 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_dict_release()

subroutine, public torch_api::torch_dict_release ( type(torch_dict_type), intent(inout) dict)

Releases a Torch dictionary and all its ressources.

Author
Ole Schuett

Definition at line 1841 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_load()

subroutine, public torch_api::torch_model_load ( type(torch_model_type), intent(inout) model,
character(len=*), intent(in) filename )

Loads a Torch model from given "*.pth" file. (In Torch lingo models are called modules).

Author
Ole Schuett

Definition at line 1865 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_load_with_metadata()

subroutine, public torch_api::torch_model_load_with_metadata ( type(torch_model_type), intent(inout) model,
character(len=*), intent(in) filename,
character(len=*), intent(in) key1,
character(:), intent(out), allocatable value1,
character(len=*), intent(in) key2,
character(:), intent(out), allocatable value2 )

Loads a Torch model and reads two metadata entries in the same archive pass.

Definition at line 1896 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_remap_device_constants()

subroutine, public torch_api::torch_model_remap_device_constants ( type(torch_model_type), intent(inout) model)

Maps serialized TorchScript device constants to the active Torch device.

Definition at line 1948 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_disable_parameter_gradients()

subroutine, public torch_api::torch_model_disable_parameter_gradients ( type(torch_model_type), intent(inout) model)

Disable gradients for inference-only model parameters.

Definition at line 1971 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_forward()

subroutine, public torch_api::torch_model_forward ( type(torch_model_type), intent(inout) model,
type(torch_dict_type), intent(in) inputs,
type(torch_dict_type), intent(inout) outputs )

Evaluates the given Torch model.

Author
Ole Schuett

Definition at line 1995 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_forward_mol_tensor()

subroutine, public torch_api::torch_model_forward_mol_tensor ( type(torch_model_type), intent(inout) model,
character(len=*), intent(in) method_name,
type(torch_dict_type), intent(in) inputs,
type(torch_tensor_type), intent(inout) output )

Evaluates a TorchScript model method expecting keyword argument "mol".

Definition at line 2030 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_release()

subroutine, public torch_api::torch_model_release ( type(torch_model_type), intent(inout) model)

Releases a Torch model and all its ressources.

Author
Ole Schuett

Definition at line 2074 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_read_metadata()

character(:) function, allocatable, public torch_api::torch_model_read_metadata ( character(len=*), intent(in) filename,
character(len=*), intent(in) key )

Reads metadata entry from given "*.pth" file. (In Torch lingo they are called extra files).

Author
Ole Schuett

Definition at line 2098 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_cuda_is_available()

logical function, public torch_api::torch_cuda_is_available

Returns true iff the Torch CUDA backend is available.

Author
Ole Schuett

Definition at line 2184 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_cuda_device_count()

integer function, public torch_api::torch_cuda_device_count

Return the number of CUDA devices visible to Torch.

Definition at line 2205 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_allow_tf32()

subroutine, public torch_api::torch_allow_tf32 ( logical, intent(in) allow_tf32)

Set whether to allow the use of TF32. Needed due to changes in defaults from pytorch 1.7 to 1.11 to >=1.12 See https://pytorch.org/docs/stable/notes/cuda.html.

Author
Gabriele Tocci

Definition at line 2229 of file torch_api.F.

Here is the caller graph for this function:

◆ torch_model_freeze()

subroutine, public torch_api::torch_model_freeze ( type(torch_model_type), intent(inout) model)

Freeze the given Torch model: applies generic optimization that speed up model. See https://pytorch.org/docs/stable/generated/torch.jit.freeze.html.

Author
Gabriele Tocci

Definition at line 2252 of file torch_api.F.

◆ torch_model_freeze_preserving_method()

subroutine, public torch_api::torch_model_freeze_preserving_method ( type(torch_model_type), intent(inout) model,
character(len=*), intent(in) method_name )

Freeze a Torch model while preserving one exported method.

Parameters
model...
method_name...

Definition at line 2281 of file torch_api.F.

Here is the caller graph for this function: