Module containing the types and interfaces of a message passing layer
Interface for setting up the MPNN layer
Set up the MPNN layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in), | dimension(2) | :: | num_features |
MAKE THESE ASSUMED RANK ! MAKE THESE ASSUMED RANK Number of features |
|
| integer, | intent(in) | :: | num_time_steps |
Number of time steps |
||
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
Instance of the message passing layer
Forward pass for the message passing layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(inout) | :: | this |
Instance of the layer type |
||
| class(array_type), | intent(in), | dimension(:,:) | :: | input |
Input data (i.e. vertex and edge features) |
Interfaces for handling learnable parameters and gradients
Get the number of learnable parameters for the message passing layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(in) | :: | this |
Instance of the message passing layer |
Number of learnable parameters
Interfaces for handling graphs and outputs, and initialising the layer
Initialise the message passing layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(inout) | :: | this |
Instance of the message passing layer |
||
| integer, | intent(in), | dimension(:) | :: | input_shape |
Input shape |
|
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
Interfaces for handling learnable parameters and gradients
Set the graph structure of the input data
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| type(graph_type), | intent(in), | dimension(:) | :: | graph |
Graph structure of input data |
interface for the message forward and backward passes
Update the message
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(inout), | target | :: | this |
Instance of the message passing layer |
|
| class(array_type), | intent(in), | dimension(:,:), target | :: | input |
Input data (i.e. vertex and edge features) |
interface for the readout forward and backward passes
Update the message
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(msgpass_layer_type), | intent(inout), | target | :: | this |
Instance of the message passing layer |
Type for message passing layer with overloaded procedures
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| class(base_actv_type), | public, | allocatable | :: | activation |
Activation function |
||
| class(base_init_type), | public, | allocatable | :: | bias_init |
Initialisers for kernel and bias |
||
| character(len=14), | public | :: | bias_initialiser | = | '' |
Initialisers for kernel and bias |
|
| integer, | public, | allocatable, dimension(:) | :: | bias_shape |
Shape of biases |
||
| type(graph_type), | public, | allocatable, dimension(:) | :: | graph |
Graph structure of input data |
||
| integer, | public | :: | id |
Unique identifier |
|||
| logical, | public | :: | inference | = | .false. |
Inference mode |
|
| integer, | public | :: | input_rank | = | 0 |
Rank of input data |
|
| integer, | public, | allocatable, dimension(:) | :: | input_shape |
Input shape |
||
| class(base_init_type), | public, | allocatable | :: | kernel_init |
Initialisers for kernel and bias |
||
| character(len=14), | public | :: | kernel_initialiser | = | '' |
Initialisers for kernel and bias |
|
| character(len=:), | public, | allocatable | :: | name |
Layer name |
||
| integer, | public, | dimension(:), allocatable | :: | num_edge_features |
Number of edge features for each time step |
||
| integer, | public | :: | num_output_edge_features |
Number of output edge features |
|||
| integer, | public | :: | num_output_vertex_features |
Number of output vertex features |
|||
| integer, | public | :: | num_outputs |
Number of outputs (if output is not graph structure) |
|||
| integer, | public | :: | num_params | = | 0 |
Number of learnable parameters |
|
| integer, | public, | dimension(:), allocatable | :: | num_params_msg |
Number of learnable parameters for each message |
||
| integer, | public | :: | num_params_readout |
Number of learnable parameters for the readout |
|||
| integer, | public | :: | num_time_steps |
Number of time steps |
|||
| integer, | public, | dimension(:), allocatable | :: | num_vertex_features |
Number of vertex features for each time step |
||
| class(array_type), | public, | allocatable, dimension(:,:) | :: | output |
Output |
||
| integer, | public | :: | output_rank | = | 0 |
Rank of output data |
|
| integer, | public, | allocatable, dimension(:) | :: | output_shape |
Output shape |
||
| type(array_type), | public, | allocatable, dimension(:) | :: | params |
Learnable parameters |
||
| character(len=20), | public | :: | subtype | = | repeat(" ", 20) | ||
| character(len=4), | public | :: | type | = | 'base' |
Layer type |
|
| logical, | public | :: | use_bias | = | .false. |
Layer has bias |
|
| logical, | public | :: | use_graph_input | = | .false. |
Use graph input |
|
| logical, | public | :: | use_graph_output | = | .false. |
Use graph output |
|
| integer, | public, | allocatable, dimension(:,:) | :: | weight_shape |
Shape of weights |
Interface for setting up the MPNN layer
| private module function layer_setup (num_features, num_time_steps, verbose) | Set up the MPNN layer |
| procedure, public :: add_t_t => add_learnable | Add two layers |
| procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base | Build layer from ONNX node and initialiser |
| procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base | Emit graph input tensor declarations for this layer |
| procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base | Emit ONNX JSON nodes for this layer (format-aware and polymorphic) |
| procedure, public, pass(this) :: extract_output => extract_output_base | Extract the output of the layer as a standard real array |
| procedure, public, pass(this) :: forward => forward_msgpass | Forward pass for message passing layer |
| procedure, public, pass(this) :: forward_eval => forward_eval_base | Forward pass of layer and return output for evaluation |
| procedure, public, pass(this) :: get_attributes => get_attributes_base | Get the attributes of the layer (for ONNX export) |
| procedure, public, pass(this) :: get_gradients | Get parameter gradients of layer |
| procedure, public, pass(this) :: get_num_params => get_num_params_msgpass | Get the number of learnable parameters for message passing layer |
| procedure, public, pass(this) :: get_params | Get learnable parameters of layer |
| procedure, public, pass(this) :: init => init_msgpass | Initialise message passing layer |
| procedure, public, pass(this) :: nullify_graph => nullify_graph_base | Nullify the forward pass data of the layer to free memory |
| generic, public :: operator(+) => add_t_t | Operator overloading for addition |
| procedure, public, pass(this) :: print => print_base | Print the layer to a file with additional information |
| procedure, public, pass(this) :: print_to_unit => print_to_unit_base | Print the layer to a unit |
| procedure(read_layer), public, deferred, pass(this) :: read | Read layer from file |
| procedure, public, pass(this) :: reduce => reduce_learnable | Merge another learnable layer into this one |
| procedure, public, pass(this) :: set_gradients | Set learnable parameters of layer |
| procedure, public, pass(this) :: set_graph => set_graph_msgpass | |
| procedure, public, pass(this) :: set_params | Set learnable parameters of layer |
| procedure, public, pass(this) :: set_rank => set_rank_base | Set the input and output ranks of the layer |
| procedure, public, pass(this) :: set_shape => set_shape_base | Set the input shape of the layer |
| procedure(update_message_msgpass), public, deferred, pass(this) :: update_message | Update the message |
| procedure(update_readout_msgpass), public, deferred, pass(this) :: update_readout | Update the readout |