Submodule containing the ONNX export procedures.
This submodule contains the routines that serialise ATHENA networks to the JSON representation used for ONNX interchange.
Resolve the ONNX export format into the internal integer selector.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(in), | optional | :: | format |
Export format as a string name or integer selector |
Integer selector for the export format (1=athena_abstract, 2=onnx_expanded)
Build the metadata entry required to reconstruct a GNN layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | layer |
GNN layer instance |
||
| character(len=*), | intent(in) | :: | prefix |
Node prefix used for this exported layer |
||
| character(len=4096), | intent(inout) | :: | metadata(:) |
Metadata strings to append to |
||
| integer, | intent(inout) | :: | num_meta |
Number of metadata entries |
Build the ONNX graph input tensor specifications.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| integer, | intent(in) | :: | ifmt |
Export format selector |
||
| type(onnx_tensor_type), | intent(inout) | :: | graph_inputs(:) |
Graph input tensor specifications |
||
| integer, | intent(inout) | :: | num_inputs |
Number of graph inputs |
Build the ONNX graph output tensor specifications.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| integer, | intent(in) | :: | ifmt |
Export format selector |
||
| type(onnx_tensor_type), | intent(inout) | :: | graph_outputs(:) |
Graph output tensor specifications |
||
| integer, | intent(inout) | :: | num_outputs |
Number of graph outputs |
Build the ONNX nodes, initialisers and GNN metadata.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| integer, | intent(in) | :: | ifmt |
Export format selector |
||
| type(onnx_node_type), | intent(inout) | :: | nodes(:) |
Exported ONNX nodes |
||
| integer, | intent(inout) | :: | num_nodes |
Node counter and allocation limit |
||
| integer, | intent(inout) | :: | max_nodes |
Node counter and allocation limit |
||
| type(onnx_initialiser_type), | intent(inout) | :: | inits(:) |
Exported ONNX initialisers |
||
| integer, | intent(inout) | :: | num_inits |
Initialiser counter and allocation limit |
||
| integer, | intent(inout) | :: | max_inits |
Initialiser counter and allocation limit |
||
| character(len=4096), | intent(inout) | :: | gnn_metadata(:) |
Exported GNN metadata entries |
||
| integer, | intent(inout) | :: | num_gnn_meta |
Number of metadata entries |
Emit Identity nodes that rename GNN inputs to the expected convention.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| integer, | intent(in) | :: | layer_id |
Layer identifier and vertex position |
||
| integer, | intent(in) | :: | vertex_idx |
Layer identifier and vertex position |
||
| type(onnx_node_type), | intent(inout) | :: | nodes(:) |
Exported ONNX nodes |
||
| integer, | intent(inout) | :: | num_nodes |
Number of exported nodes |
Emit ONNX node records for a standard, non-GNN layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| integer, | intent(in) | :: | layer_id |
Layer identifier and vertex position |
||
| integer, | intent(in) | :: | vertex_idx |
Layer identifier and vertex position |
||
| type(onnx_node_type), | intent(inout) | :: | nodes(:) |
Exported ONNX nodes |
||
| integer, | intent(inout) | :: | num_nodes |
Node counter and allocation limit |
||
| integer, | intent(inout) | :: | max_nodes |
Node counter and allocation limit |
||
| type(onnx_initialiser_type), | intent(inout) | :: | inits(:) |
Exported ONNX initialisers |
||
| integer, | intent(inout) | :: | num_inits |
Initialiser counter and allocation limit |
||
| integer, | intent(inout) | :: | max_inits |
Initialiser counter and allocation limit |
Allocate the working arrays used during ONNX export.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| type(onnx_node_type), | intent(out), | allocatable | :: | nodes(:) |
Exported node storage |
|
| type(onnx_initialiser_type), | intent(out), | allocatable | :: | inits(:) |
Exported initialiser storage |
|
| type(onnx_tensor_type), | intent(out), | allocatable | :: | graph_inputs(:) |
Exported graph input storage |
|
| type(onnx_tensor_type), | intent(out), | allocatable | :: | graph_outputs(:) |
Exported graph output storage |
|
| character(len=4096), | intent(out), | allocatable | :: | gnn_metadata(:) |
Metadata storage for GNN layers |
|
| integer, | intent(out) | :: | max_nodes |
Pre-allocation sizes |
||
| integer, | intent(out) | :: | max_inits |
Pre-allocation sizes |
Resolve the downstream tensor name after emitting one PyTorch-format NOP.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | layer | |||
| character(len=*), | intent(in) | :: | prefix | |||
| logical, | intent(in) | :: | is_last_layer | |||
| character(len=128), | intent(inout) | :: | output |
Write the collected export data to disk.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file |
Output file name |
||
| integer, | intent(in) | :: | ifmt |
Export format selector |
||
| type(onnx_node_type), | intent(in) | :: | nodes(:) |
Exported ONNX nodes |
||
| integer, | intent(in) | :: | num_nodes |
Number of exported nodes |
||
| type(onnx_initialiser_type), | intent(in) | :: | inits(:) |
Exported ONNX initialisers |
||
| integer, | intent(in) | :: | num_inits |
Number of exported initialisers |
||
| type(onnx_tensor_type), | intent(in) | :: | graph_inputs(:) |
Graph input tensor specifications |
||
| integer, | intent(in) | :: | num_inputs |
Number of graph inputs |
||
| type(onnx_tensor_type), | intent(in) | :: | graph_outputs(:) |
Graph output tensor specifications |
||
| integer, | intent(in) | :: | num_outputs |
Number of graph outputs |
||
| character(len=4096), | intent(in) | :: | gnn_metadata(:) |
GNN metadata strings |
||
| integer, | intent(in) | :: | num_gnn_meta |
Number of metadata entries |
Export a network to ONNX JSON format.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file |
Output file name |
||
| class(network_type), | intent(in) | :: | network |
Instance of the network |
||
| class(*), | intent(in), | optional | :: | format |
Export format: 'athena_abstract' (default) or 'onnx_expanded' |