get_attributes_ono_attn Function

private function get_attributes_ono_attn(this) result(attributes)

Return list of orthogonal attention attributes for ONNX export

Type Bound

orthogonal_attention_layer_type

Arguments

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

Instance of the orthogonal attention layer

Return Value type(onnx_attribute_type), allocatable, dimension(:)

List of attributes for ONNX export


Source Code

  function get_attributes_ono_attn(this) result(attributes)
    !! Return list of orthogonal attention attributes for ONNX export
    implicit none

    ! Arguments
    class(orthogonal_attention_layer_type), intent(in) :: this
    !! Instance of the orthogonal attention layer
    type(onnx_attribute_type), allocatable, dimension(:) :: attributes
    !! List of attributes for ONNX export

    ! Local variables
    character(32) :: buffer
    !! Buffer for integer-to-string conversion

    allocate(attributes(6))

    write(buffer, '(I0)') this%num_inputs
    attributes(1) = onnx_attribute_type( &
         name='num_inputs', type='int', val=trim(buffer))
    write(buffer, '(I0)') this%num_outputs
    attributes(2) = onnx_attribute_type( &
         name='num_outputs', type='int', val=trim(buffer))
    write(buffer, '(I0)') this%num_basis
    attributes(3) = onnx_attribute_type( &
         name='num_basis', type='int', val=trim(buffer))
    write(buffer, '(I0)') this%key_dim
    attributes(4) = onnx_attribute_type( &
         name='key_dim', type='int', val=trim(buffer))
    if(this%use_bias)then
       buffer = '1'
    else
       buffer = '0'
    end if
    attributes(5) = onnx_attribute_type( &
         name='use_bias', type='int', val=trim(buffer))
    attributes(6) = onnx_attribute_type( &
         name='activation', type='string', val=trim(this%activation%name))

  end function get_attributes_ono_attn