emit_constant_of_shape_float Subroutine

public subroutine emit_constant_of_shape_float(name, shape_input, value, output, nodes, num_nodes, inits, num_inits)

Emit a ConstantOfShape node

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Node name, shape tensor input, and output tensor name

character(len=*), intent(in) :: shape_input

Node name, shape tensor input, and output tensor name

real(kind=real32), intent(in) :: value

Fill value to use for the generated tensor

character(len=*), intent(in) :: output

Node name, shape tensor input, and output tensor name

type(onnx_node_type), intent(inout), dimension(:) :: nodes

Node accumulator array

integer, intent(inout) :: num_nodes

Current number of populated nodes

type(onnx_initialiser_type), intent(inout), dimension(:) :: inits

Initialiser accumulator array (unused, kept for interface symmetry)

integer, intent(inout) :: num_inits

Current number of populated initialisers (unused)


Source Code

  subroutine emit_constant_of_shape_float(name, shape_input, value, output, &
       nodes, num_nodes, inits, num_inits)
    !! Emit a ConstantOfShape node
    implicit none

    ! Arguments
    character(*), intent(in) :: name, shape_input, output
    !! Node name, shape tensor input, and output tensor name
    real(real32), intent(in) :: value
    !! Fill value to use for the generated tensor
    type(onnx_node_type), intent(inout), dimension(:) :: nodes
    !! Node accumulator array
    integer, intent(inout) :: num_nodes
    !! Current number of populated nodes
    type(onnx_initialiser_type), intent(inout), dimension(:) :: inits
    !! Initialiser accumulator array (unused, kept for interface symmetry)
    integer, intent(inout) :: num_inits
    !! Current number of populated initialisers (unused)

    ! Local variables
    character(4096) :: attr_str
    !! Serialized ONNX attribute JSON for the fill tensor
    character(256) :: raw_b64
    !! Base64-encoded fill value

    call encode_float32_base64([value], 1, raw_b64)

    attr_str = '        "attribute": [{"name": "value", "t": {' // &
         '"dims": ["1"], "dataType": 1, "rawData": "' // &
         trim(raw_b64) // '"}, "type": "TENSOR"}]'

    call emit_node('ConstantOfShape', name, output, &
         trim(attr_str), nodes, num_nodes, &
         in1=shape_input)

  end subroutine emit_constant_of_shape_float