initialise_export_storage Subroutine

subroutine initialise_export_storage(network, nodes, inits, graph_inputs, graph_outputs, gnn_metadata, max_nodes, max_inits)

Allocate the working arrays used during ONNX export.

Arguments

Type IntentOptional 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


Source Code

  subroutine initialise_export_storage( &
       network, nodes, inits, graph_inputs, graph_outputs, gnn_metadata, &
       max_nodes, max_inits)
    !! Allocate the working arrays used during ONNX export.
    implicit none

    ! Arguments
    class(network_type), intent(in) :: network
    !! Instance of the network
    type(onnx_node_type), allocatable, intent(out) :: nodes(:)
    !! Exported node storage
    type(onnx_initialiser_type), allocatable, intent(out) :: inits(:)
    !! Exported initialiser storage
    type(onnx_tensor_type), allocatable, intent(out) :: graph_inputs(:)
    !! Exported graph input storage
    type(onnx_tensor_type), allocatable, intent(out) :: graph_outputs(:)
    !! Exported graph output storage
    character(4096), allocatable, intent(out) :: gnn_metadata(:)
    !! Metadata storage for GNN layers
    integer, intent(out) :: max_nodes, max_inits
    !! Pre-allocation sizes

    max_nodes = network%auto_graph%num_vertices * 60
    max_inits = network%auto_graph%num_vertices * 30

    allocate(nodes(max_nodes))
    allocate(inits(max_inits))
    allocate(graph_inputs(network%auto_graph%num_vertices * 5))
    allocate(graph_outputs(network%auto_graph%num_vertices * 3))
    allocate(gnn_metadata(network%auto_graph%num_vertices))

  end subroutine initialise_export_storage