Skip to content

mod_forward_gradient_batched

Lines: 175 | Visibility: private

Universal routines for batchwise forward gradient passes. author: Alexander Knoll

Dependencies

Uses

module~~mod_forward_gradient_batched~~UsesGraph module~mod_forward_gradient_batched mod_forward_gradient_batched module~mod_abstract_property_model mod_abstract_property_model module~mod_forward_gradient_batched->module~mod_abstract_property_model module~mod_databatcher mod_databatcher module~mod_forward_gradient_batched->module~mod_databatcher module~mod_mpi mod_mpi module~mod_forward_gradient_batched->module~mod_mpi module~mod_periodic_table mod_periodic_table module~mod_forward_gradient_batched->module~mod_periodic_table module~mod_precision mod_precision module~mod_forward_gradient_batched->module~mod_precision module~mod_abstract_property_model->module~mod_precision module~mod_array_helpers mod_array_helpers module~mod_abstract_property_model->module~mod_array_helpers module~mod_initialize_array mod_initialize_array module~mod_abstract_property_model->module~mod_initialize_array module~mod_io mod_io module~mod_abstract_property_model->module~mod_io module~mod_random mod_random module~mod_abstract_property_model->module~mod_random module~mod_settings mod_settings module~mod_abstract_property_model->module~mod_settings module~mod_throw mod_throw module~mod_abstract_property_model->module~mod_throw module~mod_databatcher->module~mod_mpi module~mod_databatcher->module~mod_precision module~mod_databatcher->module~mod_array_helpers module~mod_databatcher->module~mod_random module~mod_databatcher->module~mod_throw module~mod_mpi->module~mod_precision mpi_f08 mpi_f08 module~mod_mpi->mpi_f08 module~mod_periodic_table->module~mod_precision module~mod_periodic_table->module~mod_array_helpers module~mod_constants mod_constants module~mod_periodic_table->module~mod_constants module~mod_periodic_table->module~mod_io module~mod_periodic_table->module~mod_throw iso_c_binding iso_c_binding module~mod_precision->iso_c_binding iso_fortran_env iso_fortran_env module~mod_precision->iso_fortran_env module~mod_array_helpers->module~mod_precision module~mod_array_helpers->module~mod_throw module~mod_constants->module~mod_precision module~mod_constants->iso_c_binding module~mod_initialize_array->module~mod_mpi module~mod_initialize_array->module~mod_precision module~mod_initialize_array->module~mod_io module~mod_initialize_array->module~mod_random module~mod_initialize_array->module~mod_throw module~mod_parameter_file mod_parameter_file module~mod_initialize_array->module~mod_parameter_file module~mod_io->module~mod_precision module~mod_io->iso_fortran_env module~mod_optional_args mod_optional_args module~mod_io->module~mod_optional_args module~mod_random->module~mod_precision module~mod_random->module~mod_constants module~mod_settings->module~mod_periodic_table module~mod_settings->module~mod_precision module~mod_settings->module~mod_constants module~mod_settings->module~mod_io module~mod_settings->module~mod_throw module~mod_cpu_vendor mod_cpu_vendor module~mod_settings->module~mod_cpu_vendor module~mod_throw->module~mod_mpi module~mod_throw->module~mod_precision module~mod_throw->iso_c_binding module~mod_throw->iso_fortran_env module~mod_throw->module~mod_io module~mod_sort mod_sort module~mod_throw->module~mod_sort module~mod_cpu_vendor->iso_c_binding module~mod_parameter_file->module~mod_precision module~mod_parameter_file->module~mod_io module~mod_parameter_file->module~mod_throw module~mod_abstract_broadcast_file mod_abstract_broadcast_file module~mod_parameter_file->module~mod_abstract_broadcast_file module~mod_nan_check mod_nan_check module~mod_parameter_file->module~mod_nan_check module~mod_sort->module~mod_precision module~mod_abstract_broadcast_file->module~mod_mpi module~mod_abstract_broadcast_file->module~mod_io module~mod_abstract_broadcast_file->module~mod_throw module~mod_genericfile mod_genericfile module~mod_abstract_broadcast_file->module~mod_genericfile module~mod_sanitize mod_sanitize module~mod_abstract_broadcast_file->module~mod_sanitize module~mod_nan_check->module~mod_precision module~mod_nan_check->module~mod_io module~mod_nan_check->module~mod_throw ieee_arithmetic ieee_arithmetic module~mod_nan_check->ieee_arithmetic module~mod_genericfile->module~mod_mpi module~mod_genericfile->module~mod_io module~mod_genericfile->module~mod_throw module~mod_sanitize->module~mod_throw

Used By

module~~mod_forward_gradient_batched~~UsedByGraph module~mod_forward_gradient_batched mod_forward_gradient_batched module~mod_train_forces_multiple_structures mod_train_forces_multiple_structures module~mod_train_forces_multiple_structures->module~mod_forward_gradient_batched module~mod_train_loop_short_range mod_train_loop_short_range module~mod_train_loop_short_range->module~mod_train_forces_multiple_structures module~mod_train_mode mod_train_mode module~mod_train_mode->module~mod_train_loop_short_range program~runner RuNNer program~runner->module~mod_train_mode

Procedures Summary

Name Type Description
forward_gradient_batched_multiple_models Subroutine Pass an array of features and their gradients forward through multiple models model in batches. ...
forward_gradient_batched_single_model Subroutine Pass an array of features and their gradients forward through multiple models model in batches. ...
forward_gradient_and_store_with_extra_features Subroutine
forward_gradient_and_store Subroutine

Interface Details

interface forward_gradient_batched


Procedure Details

subroutine forward_gradient_batched_multiple_models

subroutine forward_gradient_batched_multiple_models( &
    models, &
    model_indices, &
    features, &
    feature_derivatives, &
    num_extra_features, &
    extra_features, &
    extra_feature_derivatives, &
    xyz_indices, &
    central_to_target_atom_map, &
    num_features, &
    batchsize, &
    atomic_numbers, &
    model_output &
)

Pass an array of features and their gradients forward through multiple models model in batches.

In this routine, we expect that each given sample provides a contribution to the property of a target atom. Therefore, xyz_indices does not have to be given for each sample, but only for each target atom. The connection is made through central_to_target_atom_map.

Arguments

  • models : type(ModelPtr) (dim: (:,:)) [inout]– The models through which the forward pass will be performed.
  • model_indices : integer (dim: (:)) [in]
  • features : real(DP) (dim: (:,:)) [inout]– The feature values for each sample (max_num_features x num_samples).
  • feature_derivatives : real(DP) (dim: (:,:,:)) [in]– The derivatives of `features` along Cartesian axes (3 x max_num_features x num_samples).
  • num_extra_features : integer (dim: (size(models,2))) [in]
  • extra_features : real(DP) (dim: (:,:,:,:)) [in]– Dimensions: (maxval(num_extra_features), num_samples, committee_size, num_models).
  • extra_feature_derivatives : real(DP) (dim: (:,:,:,:,:)) [in]– Dimensions: (3, maxval(num_extra_features), num_samples, committee_size, num_models).
  • xyz_indices : integer (dim: (:)) [in]– The target xyz indices. This does not have length `num_samples` but length `num_target_atoms` instead. For each sample, only the gradient belong towards the target xyz component is passed forward.
  • central_to_target_atom_map : integer (dim: (:)) [in]– Tells us which target atom a sample belongs to.
  • num_features : integer (dim: (MAX_ELEM_NUM)) [in]– The number of features for each atomic number in `features.
  • batchsize : integer (dim: (MAX_ELEM_NUM)) [in]– How large the batches are supposed to be for each atomic number.
  • atomic_numbers : integer (dim: (:)) [in]– The atomic number belonging to each sample in `features`
  • model_output : real(DP) (dim: (:,:,:,:)) [out]– The output of the model for each given sample. The values will be returned in the order in which the appeared in `features`. This is different from the order of the batched forward pass, which works through all batches of one atomic number before starting the next one. Dimensions: (num_samples, num_output_values, committee_size, num_models).

Called By

proc~~forward_gradient_batched_multiple_models~~CalledByGraph proc~forward_gradient_batched_multiple_models mod_forward_gradient_batched::forward_gradient_batched_multiple_models interface~forward_gradient_batched mod_forward_gradient_batched::forward_gradient_batched interface~forward_gradient_batched->proc~forward_gradient_batched_multiple_models proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~forward_gradient_batched proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine forward_gradient_batched_single_model

subroutine forward_gradient_batched_single_model( &
    models, &
    features, &
    feature_derivatives, &
    num_extra_features, &
    extra_features, &
    extra_feature_derivatives, &
    xyz_indices, &
    central_to_target_atom_map, &
    num_features, &
    batchsize, &
    atomic_numbers, &
    model_output &
)

Pass an array of features and their gradients forward through multiple models model in batches.

In this routine, we expect that each given sample provides a contribution to the property of a target atom. Therefore, xyz_indices does not have to be given for each sample, but only for each target atom. The connection is made through central_to_target_atom_map.

Arguments

  • models : type(ModelPtr) (dim: (:)) [inout]– The models through which the forward pass will be performed.
  • features : real(DP) (dim: (:,:)) [inout]– The feature values for each sample (max_num_features x num_samples).
  • feature_derivatives : real(DP) (dim: (:,:,:)) [in]– The derivatives of `features` along Cartesian axes (3 x max_num_features x num_samples).
  • num_extra_features : integer [in]
  • extra_features : real(DP) (dim: (:,:,:)) [in]– Dimensions: (maxval(num_extra_features), num_samples, committee_size).
  • extra_feature_derivatives : real(DP) (dim: (:,:,:,:)) [in]– Dimensions: (3, maxval(num_extra_features), num_samples, committee_size).
  • xyz_indices : integer (dim: (:)) [in]– The target xyz indices. This does not have length `num_samples` but length `num_target_atoms` instead. For each sample, only the gradient belong towards the target xyz component is passed forward.
  • central_to_target_atom_map : integer (dim: (:)) [in]– Tells us which target atom a sample belongs to.
  • num_features : integer (dim: (MAX_ELEM_NUM)) [in]– The number of features for each atomic number in `features.
  • batchsize : integer (dim: (MAX_ELEM_NUM)) [in]– How large the batches are supposed to be for each atomic number.
  • atomic_numbers : integer (dim: (:)) [in]– The atomic number belonging to each sample in `features`
  • model_output : real(DP) (dim: (:,:,:)) [out]– The output of the model for each given sample. The values will be returned in the order in which the appeared in `features`. This is different from the order of the batched forward pass, which works through all batches of one atomic number before starting the next one. Dimensions: (num_samples, num_output_values, committee_size).

Called By

proc~~forward_gradient_batched_single_model~~CalledByGraph proc~forward_gradient_batched_single_model mod_forward_gradient_batched::forward_gradient_batched_single_model interface~forward_gradient_batched mod_forward_gradient_batched::forward_gradient_batched interface~forward_gradient_batched->proc~forward_gradient_batched_single_model proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~forward_gradient_batched proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine forward_gradient_and_store_with_extra_features

subroutine forward_gradient_and_store_with_extra_features( &
    model, &
    features, &
    feature_derivatives, &
    num_extra_features, &
    extra_features, &
    extra_feature_derivatives, &
    ids, &
    xyz_indices, &
    central_to_target_atom_map, &
    num_features, &
    atomic_numbers, &
    model_output &
)

Arguments

  • model : class(AbstractPropertyModel) [inout]
  • features : real(DP) (dim: (:,:)) [inout]
  • feature_derivatives : real(DP) (dim: (:,:,:)) [in]
  • num_extra_features : integer [in]
  • extra_features : real(DP) (dim: (:,:)) [in]
  • extra_feature_derivatives : real(DP) (dim: (:,:,:)) [in]
  • ids : integer (dim: (:)) [in]
  • xyz_indices : integer (dim: (:)) [in]
  • central_to_target_atom_map : integer (dim: (:)) [in]
  • num_features : integer (dim: (MAX_ELEM_NUM)) [in]
  • atomic_numbers : integer (dim: (:)) [in]
  • model_output : real(DP) (dim: (:,:)) [out]

Called By

proc~~forward_gradient_and_store_with_extra_features~~CalledByGraph proc~forward_gradient_and_store_with_extra_features mod_forward_gradient_batched::forward_gradient_and_store_with_extra_features proc~forward_gradient_batched_multiple_models mod_forward_gradient_batched::forward_gradient_batched_multiple_models proc~forward_gradient_batched_multiple_models->proc~forward_gradient_and_store_with_extra_features proc~forward_gradient_batched_single_model mod_forward_gradient_batched::forward_gradient_batched_single_model proc~forward_gradient_batched_single_model->proc~forward_gradient_and_store_with_extra_features interface~forward_gradient_batched mod_forward_gradient_batched::forward_gradient_batched interface~forward_gradient_batched->proc~forward_gradient_batched_multiple_models interface~forward_gradient_batched->proc~forward_gradient_batched_single_model proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~forward_gradient_batched proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine forward_gradient_and_store

subroutine forward_gradient_and_store( &
    model, &
    features, &
    feature_derivatives, &
    ids, &
    xyz_indices, &
    central_to_target_atom_map, &
    num_features, &
    atomic_numbers, &
    model_output &
)

Arguments

  • model : class(AbstractPropertyModel) [inout]
  • features : real(DP) (dim: (:,:)) [inout]
  • feature_derivatives : real(DP) (dim: (:,:,:)) [in]
  • ids : integer (dim: (:)) [in]
  • xyz_indices : integer (dim: (:)) [in]
  • central_to_target_atom_map : integer (dim: (:)) [in]
  • num_features : integer (dim: (MAX_ELEM_NUM)) [in]
  • atomic_numbers : integer (dim: (:)) [in]
  • model_output : real(DP) (dim: (:,:)) [out]

Called By

proc~~forward_gradient_and_store~~CalledByGraph proc~forward_gradient_and_store mod_forward_gradient_batched::forward_gradient_and_store proc~forward_gradient_batched_multiple_models mod_forward_gradient_batched::forward_gradient_batched_multiple_models proc~forward_gradient_batched_multiple_models->proc~forward_gradient_and_store proc~forward_gradient_batched_single_model mod_forward_gradient_batched::forward_gradient_batched_single_model proc~forward_gradient_batched_single_model->proc~forward_gradient_and_store interface~forward_gradient_batched mod_forward_gradient_batched::forward_gradient_batched interface~forward_gradient_batched->proc~forward_gradient_batched_multiple_models interface~forward_gradient_batched->proc~forward_gradient_batched_single_model proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~forward_gradient_batched proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode