Emit an activation function node
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
Activation name, node prefix, and optional override for the input name |
||
| character(len=*), | intent(in) | :: | prefix |
Activation name, node prefix, and optional override for the input name |
||
| character(len=*), | intent(in) | :: | input_override |
Activation name, node prefix, and optional override for the input name |
||
| type(onnx_node_type), | intent(inout), | dimension(:) | :: | nodes |
Node accumulator array |
|
| integer, | intent(inout) | :: | num_nodes |
Current number of populated nodes |
||
| integer, | intent(in) | :: | max_nodes |
Maximum number of nodes available in the accumulator |
subroutine emit_activation_node(name, prefix, input_override, & nodes, num_nodes, max_nodes) !! Emit an activation function node use coreutils, only: to_camel_case implicit none ! Arguments character(*), intent(in) :: name, prefix, input_override !! Activation name, node prefix, and optional override for the input name type(onnx_node_type), intent(inout), dimension(:) :: nodes !! Node accumulator array integer, intent(inout) :: num_nodes !! Current number of populated nodes integer, intent(in) :: max_nodes !! Maximum number of nodes available in the accumulator ! Local variables character(128) :: actv_name, input_n, output_n !! Normalised ONNX op name, input tensor name, and output tensor name character(4096) :: attr_str !! Serialized ONNX attribute JSON for activation-specific options actv_name = to_camel_case( & trim(adjustl(name)), & capitalise_first_letter = .true.) if(len_trim(input_override) .gt. 0)then input_n = trim(input_override) else input_n = trim(prefix) // '_output' end if output_n = trim(prefix) // '_' // trim(adjustl(name)) // '_output' attr_str = '' ! LeakyRelu needs alpha attribute if(trim(name) .eq. 'leaky_relu')then actv_name = 'LeakyRelu' attr_str = ' "attribute": [{"name": "alpha", ' // & '"f": 0.01, "type": "FLOAT"}]' end if call emit_node(trim(actv_name), & trim(prefix)//'_'//trim(adjustl(name)), & trim(output_n), trim(attr_str), nodes, num_nodes, & in1=trim(input_n)) end subroutine emit_activation_node