athena__input_layer Module

Module containing procedures for an input layer

This module implements the input layer which serves as the entry point for data into a neural network. It handles data conversion and batching.

Operation: Accepts external data and converts to internal array_type format - Validates input shape matches specified dimensions - Handles both dense arrays and graph-structured data - No learnable parameters (pass-through layer)

Properties: - First layer in any network architecture - Defines expected input shape for subsequent layers - Supports multiple input sources in multi-input networks


Uses


Interfaces

public interface input_layer_type

Interface for an input layer

  • private module function layer_setup(input_shape, index, use_graph_input, verbose) result(layer)

    Set up layer

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), optional, dimension(:) :: input_shape

    Shape of the input data

    integer, intent(in), optional :: index

    Index of the layer

    logical, intent(in), optional :: use_graph_input

    Use graph input

    integer, intent(in), optional :: verbose

    Verbosity level

    Return Value type(input_layer_type)

    Instance of the input layer


Derived Types

type, public, extends(base_layer_type) ::  input_layer_type

Type for an input layer

Components

Type Visibility Attributes Name Initial
type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

integer, public :: index = 1

Index of the layer

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_outputs

Number of outputs

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

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Constructor

Interface for an input layer

private module function layer_setup (input_shape, index, use_graph_input, verbose)

Set up layer

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_input

Build fully connected 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_input

Forward propagation derived type handler

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_num_params => get_num_params_base

Get the number of parameters in the layer

procedure, public, pass(this) :: init => init_input

Initialise layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
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_input

Print layer to unit

procedure, public, pass(this) :: read => read_input

Read layer from file

generic, public :: set => set_input_real, set_input_graph

Generic interface for setting input values

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_hyperparams => set_hyperparams_input

Set hyperparameters

procedure, public, pass(this) :: set_input_graph

Set input values

procedure, public, pass(this) :: set_input_real

Set input values

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


Functions

public function create_from_onnx_input_layer(node, initialisers, value_info, verbose) result(layer)

Build fully connected layer from attributes and return layer

Arguments

Type IntentOptional Attributes Name
type(onnx_node_type), intent(in) :: node

ONNX node information

type(onnx_initialiser_type), intent(in), dimension(:) :: initialisers

ONNX initialiser information

type(onnx_tensor_type), intent(in), dimension(:) :: value_info

ONNX value info

integer, intent(in), optional :: verbose

Verbosity level

Return Value class(base_layer_type), allocatable

Instance of the 2D convolutional layer

public function read_input_layer(unit, verbose) result(layer)

Read an input layer from a file

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Unit number

integer, intent(in), optional :: verbose

Verbosity level

Return Value class(base_layer_type), allocatable

Instance of the input layer

private module function layer_setup(input_shape, index, use_graph_input, verbose) result(layer)

Set up layer

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional, dimension(:) :: input_shape

Shape of the input data

integer, intent(in), optional :: index

Index of the layer

logical, intent(in), optional :: use_graph_input

Use graph input

integer, intent(in), optional :: verbose

Verbosity level

Return Value type(input_layer_type)

Instance of the input layer


Subroutines

private subroutine build_from_onnx_input(this, node, initialisers, value_info, verbose)

Read ONNX attributes for fully connected layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the fully connected layer

type(onnx_node_type), intent(in) :: node

ONNX node information

type(onnx_initialiser_type), intent(in), dimension(:) :: initialisers

ONNX initialiser information

type(onnx_tensor_type), intent(in), dimension(:) :: value_info

ONNX value info

integer, intent(in) :: verbose

Verbosity level

private subroutine forward_input(this, input)

Forward propagation for an input layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

class(array_type), intent(in), dimension(:,:) :: input

Input data

private subroutine init_input(this, input_shape, verbose)

Initialise an input layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

integer, intent(in), dimension(:) :: input_shape

Shape of the input data

integer, intent(in), optional :: verbose

Verbosity level

private subroutine print_to_unit_input(this, unit)

Print input layer to unit

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(in) :: this

Instance of the input layer

integer, intent(in) :: unit

File unit

private subroutine read_input(this, unit, verbose)

Read an input layer from a file

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

integer, intent(in) :: unit

Unit number

integer, intent(in), optional :: verbose

Verbosity level

private subroutine set_hyperparams_input(this, input_rank, index, use_graph_input, verbose)

Set hyperparameters for an input layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

integer, intent(in), optional :: input_rank

Rank of the input data

integer, intent(in), optional :: index

Index of the layer

logical, intent(in), optional :: use_graph_input

Use graph input

integer, intent(in), optional :: verbose

Verbosity level

private subroutine set_input_graph(this, input)

Set input values for an input layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

type(graph_type), intent(in), dimension(:) :: input

Input data

private pure subroutine set_input_real(this, input)

Set input values for an input layer

Arguments

Type IntentOptional Attributes Name
class(input_layer_type), intent(inout) :: this

Instance of the input layer

real(kind=real32), intent(in), dimension(..) :: input

Input data