| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module athena__activation | ||
| 2 | !! Module containing the activation function setup | ||
| 3 | use coreutils, only: stop_program, to_lower | ||
| 4 | use athena__misc_types, only: base_actv_type, onnx_attribute_type | ||
| 5 | use athena__activation_gaussian, only: gaussian_actv_type, & | ||
| 6 | create_from_onnx_gaussian_activation | ||
| 7 | use athena__activation_linear, only: linear_actv_type, & | ||
| 8 | create_from_onnx_linear_activation | ||
| 9 | use athena__activation_piecewise, only: piecewise_actv_type, & | ||
| 10 | create_from_onnx_piecewise_activation | ||
| 11 | use athena__activation_relu, only: relu_actv_type, & | ||
| 12 | create_from_onnx_relu_activation | ||
| 13 | use athena__activation_leaky_relu, only: leaky_relu_actv_type, & | ||
| 14 | create_from_onnx_leaky_relu_activation | ||
| 15 | use athena__activation_sigmoid, only: sigmoid_actv_type, & | ||
| 16 | create_from_onnx_sigmoid_activation | ||
| 17 | use athena__activation_softmax, only: softmax_actv_type, & | ||
| 18 | create_from_onnx_softmax_activation | ||
| 19 | use athena__activation_swish, only: swish_actv_type, & | ||
| 20 | create_from_onnx_swish_activation | ||
| 21 | use athena__activation_tanh, only: tanh_actv_type, & | ||
| 22 | create_from_onnx_tanh_activation | ||
| 23 | use athena__activation_none, only: none_actv_type, & | ||
| 24 | create_from_onnx_none_activation | ||
| 25 | use athena__activation_selu, only: selu_actv_type, & | ||
| 26 | create_from_onnx_selu_activation | ||
| 27 | implicit none | ||
| 28 | |||
| 29 | |||
| 30 | private | ||
| 31 | |||
| 32 | public :: activation_setup | ||
| 33 | public :: list_of_onnx_activation_creators | ||
| 34 | public :: allocate_list_of_onnx_activation_creators | ||
| 35 | public :: read_activation | ||
| 36 | |||
| 37 | |||
| 38 | type :: onnx_create_actv_container | ||
| 39 | !! Type containing information needed to create an activation from ONNX | ||
| 40 | character(20) :: name | ||
| 41 | !! Name of the layer | ||
| 42 | procedure(create_from_onnx_activation), nopass, pointer :: create_ptr => null() | ||
| 43 | !! Pointer to the specific activation creation function | ||
| 44 | end type onnx_create_actv_container | ||
| 45 | type(onnx_create_actv_container), dimension(:), allocatable :: & | ||
| 46 | list_of_onnx_activation_creators | ||
| 47 | !! List of activation names and their associated ONNX creation functions | ||
| 48 | |||
| 49 | interface | ||
| 50 | module function create_from_onnx_activation(attributes) result(activation) | ||
| 51 | !! Function to create an activation function from ONNX attributes | ||
| 52 | type(onnx_attribute_type), dimension(:), intent(in) :: attributes | ||
| 53 | !! Array of ONNX attributes | ||
| 54 | class(base_actv_type), allocatable :: activation | ||
| 55 | !! Resulting activation function | ||
| 56 | end function create_from_onnx_activation | ||
| 57 | end interface | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | contains | ||
| 62 | |||
| 63 | !############################################################################### | ||
| 64 | 286 | function activation_setup(input, error) result(activation) | |
| 65 | !! Setup the desired activation function | ||
| 66 | implicit none | ||
| 67 | |||
| 68 | ! Arguments | ||
| 69 | class(*), intent(in) :: input | ||
| 70 | !! Name of the activation function or activation object | ||
| 71 | class(base_actv_type), allocatable :: activation | ||
| 72 | !! Activation function object | ||
| 73 | integer, optional, intent(out) :: error | ||
| 74 | !! Error code | ||
| 75 | |||
| 76 | ! Local variables | ||
| 77 | character(256) :: err_msg | ||
| 78 | !! Error message | ||
| 79 | |||
| 80 | |||
| 81 | !--------------------------------------------------------------------------- | ||
| 82 | ! select desired activation function | ||
| 83 | !--------------------------------------------------------------------------- | ||
| 84 | select type(input) | ||
| 85 | class is(base_actv_type) | ||
| 86 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
31 | activation = input |
| 87 | type is(character(*)) | ||
| 88 | 510 | select case(trim(to_lower(input))) | |
| 89 | case("gaussian") | ||
| 90 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
2 | activation = gaussian_actv_type() |
| 91 | case ("linear") | ||
| 92 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 24 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
24 | activation = linear_actv_type() |
| 93 | case ("piecewise") | ||
| 94 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
2 | activation = piecewise_actv_type() |
| 95 | case ("relu") | ||
| 96 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 34 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
34 | activation = relu_actv_type() |
| 97 | case ("leaky_relu") | ||
| 98 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
2 | activation = leaky_relu_actv_type() |
| 99 | case ("sigmoid") | ||
| 100 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
37 | activation = sigmoid_actv_type() |
| 101 | case ("softmax") | ||
| 102 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 9 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
9 | activation = softmax_actv_type() |
| 103 | case("swish") | ||
| 104 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
8 | activation = swish_actv_type() |
| 105 | case ("tanh") | ||
| 106 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
20 | activation = tanh_actv_type() |
| 107 | case ("none") | ||
| 108 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 116 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
116 | activation = none_actv_type() |
| 109 | case ("selu") | ||
| 110 |
3/10✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
1 | activation = selu_actv_type() |
| 111 | case ("silu") | ||
| 112 | ✗ | activation = swish_actv_type() | |
| 113 | case default | ||
| 114 |
12/17✓ Branch 1 taken 255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 37 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 20 times.
✓ Branch 12 taken 116 times.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
765 | if(present(error))then |
| 115 | ✗ | error = -1 | |
| 116 | ✗ | return | |
| 117 | else | ||
| 118 | write(err_msg,'("Incorrect activation name given ''",A,"''")') & | ||
| 119 | ✗ | trim(to_lower(input)) | |
| 120 | ✗ | call stop_program(trim(err_msg)) | |
| 121 | ✗ | write(*,*) "BB" | |
| 122 | ✗ | return | |
| 123 | end if | ||
| 124 | end select | ||
| 125 | class default | ||
| 126 | ✗ | if(present(error))then | |
| 127 | ✗ | error = -1 | |
| 128 | ✗ | return | |
| 129 | else | ||
| 130 | ✗ | write(err_msg,'("Unknown input type given for activation setup")') | |
| 131 | ✗ | call stop_program(trim(err_msg)) | |
| 132 | ✗ | return | |
| 133 | end if | ||
| 134 | end select | ||
| 135 | |||
| 136 | 286 | end function activation_setup | |
| 137 | !############################################################################### | ||
| 138 | |||
| 139 | |||
| 140 | !############################################################################### | ||
| 141 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
14 | subroutine allocate_list_of_onnx_activation_creators(addit_list) |
| 142 | !! Allocate and populate the list of ONNX activation creation functions | ||
| 143 | implicit none | ||
| 144 | |||
| 145 | ! Arguments | ||
| 146 | type(onnx_create_actv_container), dimension(:), intent(in), optional :: & | ||
| 147 | addit_list | ||
| 148 | |||
| 149 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(.not.allocated(list_of_onnx_activation_creators)) & |
| 150 |
8/16✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 14 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 14 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 14 times.
|
14 | allocate(list_of_onnx_activation_creators(0)) |
| 151 | list_of_onnx_activation_creators = [ & | ||
| 152 | onnx_create_actv_container('gaussian', create_from_onnx_gaussian_activation), & | ||
| 153 | onnx_create_actv_container('leaky_relu', & | ||
| 154 | create_from_onnx_leaky_relu_activation), & | ||
| 155 | onnx_create_actv_container('linear', create_from_onnx_linear_activation), & | ||
| 156 | onnx_create_actv_container('none', create_from_onnx_none_activation), & | ||
| 157 | onnx_create_actv_container('piecewise', & | ||
| 158 | create_from_onnx_piecewise_activation), & | ||
| 159 | onnx_create_actv_container('relu', create_from_onnx_relu_activation), & | ||
| 160 | onnx_create_actv_container('selu', create_from_onnx_selu_activation), & | ||
| 161 | onnx_create_actv_container('sigmoid', create_from_onnx_sigmoid_activation), & | ||
| 162 | onnx_create_actv_container('silu', create_from_onnx_swish_activation), & | ||
| 163 | onnx_create_actv_container('softmax', create_from_onnx_softmax_activation), & | ||
| 164 | onnx_create_actv_container('swish', create_from_onnx_swish_activation), & | ||
| 165 | onnx_create_actv_container('tanh', create_from_onnx_tanh_activation) & | ||
| 166 |
7/10✓ Branch 0 taken 168 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 14 times.
✓ Branch 8 taken 168 times.
✓ Branch 9 taken 14 times.
|
350 | ] |
| 167 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if(present(addit_list))then |
| 168 | ✗ | list_of_onnx_activation_creators = [ & | |
| 169 | ✗ | list_of_onnx_activation_creators, addit_list & | |
| 170 | ✗ | ] | |
| 171 | end if | ||
| 172 | |||
| 173 | 14 | end subroutine allocate_list_of_onnx_activation_creators | |
| 174 | !############################################################################### | ||
| 175 | |||
| 176 | |||
| 177 | !############################################################################### | ||
| 178 | 15 | function read_activation_attributes(unit, iline) result(attributes) | |
| 179 | use coreutils, only: stop_program, to_lower | ||
| 180 | implicit none | ||
| 181 | |||
| 182 | ! Arguments | ||
| 183 | integer, intent(in) :: unit | ||
| 184 | !! Unit number for input file | ||
| 185 | integer, intent(inout), optional :: iline | ||
| 186 | !! Indicator for inline reading | ||
| 187 | |||
| 188 | type(onnx_attribute_type), allocatable, dimension(:) :: attributes | ||
| 189 | !! Array of ONNX attributes | ||
| 190 | |||
| 191 | ! Local variables | ||
| 192 | integer :: i | ||
| 193 | !! Loop variable | ||
| 194 | character(256) :: buffer | ||
| 195 | !! Buffer for reading lines | ||
| 196 | character(256) :: err_msg | ||
| 197 | !! Error message | ||
| 198 | character(20) :: attr_name | ||
| 199 | !! Attribute name | ||
| 200 | character(20) :: attr_value | ||
| 201 | !! Attribute value as string | ||
| 202 | integer :: stat | ||
| 203 | !! I/O status | ||
| 204 | integer :: eq_pos | ||
| 205 | !! Position of equals sign | ||
| 206 | integer :: n_attrs | ||
| 207 | !! Number of attributes | ||
| 208 | type(onnx_attribute_type), allocatable, dimension(:) :: temp_attrs | ||
| 209 | !! Temporary array for growing attributes | ||
| 210 | 15 | character(20), dimension(:), allocatable :: names | |
| 211 | !! Array of attribute names | ||
| 212 | integer :: iline_ | ||
| 213 | !! Line number | ||
| 214 | |||
| 215 | |||
| 216 | ! Initialise empty attributes array | ||
| 217 |
8/24✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 15 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 15 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 15 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
15 | allocate(attributes(0)) |
| 218 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
|
15 | allocate(names(0)) |
| 219 | 15 | iline_ = 0 | |
| 220 | |||
| 221 | ! Read lines until END or END ACTIVATION | ||
| 222 | 53 | read_loop: do | |
| 223 | 68 | read(unit,'(A)',iostat=stat) buffer | |
| 224 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
|
68 | if(stat.ne.0)then |
| 225 | ✗ | write(err_msg,'("File encountered error (EoF?) before END ACTIVATION")') | |
| 226 | ✗ | call stop_program(err_msg) | |
| 227 | ✗ | return | |
| 228 | end if | ||
| 229 | 68 | iline_ = iline_ + 1 | |
| 230 | |||
| 231 | ! Skip empty or comment lines | ||
| 232 |
2/4✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
|
68 | if(trim(adjustl(buffer)).eq."") cycle read_loop |
| 233 |
2/4✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
|
68 | if(index(trim(adjustl(buffer)),"#") .eq. 1) cycle read_loop |
| 234 |
2/4✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
|
68 | if(index(trim(adjustl(buffer)),"!") .eq. 1) cycle read_loop |
| 235 | |||
| 236 | ! Check for end of activation block | ||
| 237 |
4/6✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 68 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 53 times.
|
68 | if(trim(adjustl(buffer)).eq."END" .or. & |
| 238 | trim(adjustl(buffer)).eq."END ACTIVATION")then | ||
| 239 | 15 | exit read_loop | |
| 240 | end if | ||
| 241 | |||
| 242 | ! Look for NAME = VALUE pattern | ||
| 243 | 53 | eq_pos = scan(buffer, "=") | |
| 244 | |||
| 245 | |||
| 246 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
|
53 | if(eq_pos .gt. 0)then |
| 247 | ! Extract name (everything before =) | ||
| 248 |
3/6✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
|
38 | attr_name = to_lower(adjustl(buffer(:eq_pos-1))) |
| 249 | ! Extract value (everything after =) | ||
| 250 |
3/6✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
|
38 | attr_value = adjustl(buffer(eq_pos+1:)) |
| 251 | |||
| 252 | |||
| 253 |
2/4✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
|
38 | if(index(trim(adjustl(buffer)),"ACTIVATION") .eq. 1 .and. iline_ .eq. 1)then |
| 254 | ✗ | attributes = [ onnx_attribute_type("name", "string", trim(attr_value)) ] | |
| 255 | ✗ | exit read_loop | |
| 256 | end if | ||
| 257 | |||
| 258 | ! Check if attribute already exists | ||
| 259 |
8/14✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38 times.
✓ Branch 12 taken 31 times.
✓ Branch 13 taken 38 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 31 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 38 times.
|
69 | if(any(names .eq. attr_name))then |
| 260 | write(err_msg,'("Duplicate activation attribute name: ''",A,"''")') & | ||
| 261 | ✗ | trim(attr_name) | |
| 262 | ✗ | call stop_program(trim(err_msg)) | |
| 263 | ✗ | return | |
| 264 | end if | ||
| 265 | |||
| 266 | ! Grow attributes array | ||
| 267 | ✗ | attributes = [ & | |
| 268 | attributes, & | ||
| 269 | onnx_attribute_type( & | ||
| 270 | trim(attr_name), & | ||
| 271 | "float", & | ||
| 272 | trim(attr_value) & | ||
| 273 | ) & | ||
| 274 |
36/66✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38 times.
✓ Branch 11 taken 31 times.
✓ Branch 12 taken 38 times.
✓ Branch 15 taken 38 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 38 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 38 times.
✓ Branch 21 taken 69 times.
✓ Branch 22 taken 38 times.
✓ Branch 23 taken 69 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 69 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 69 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 69 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 38 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 38 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 38 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 38 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 31 times.
✓ Branch 44 taken 38 times.
✓ Branch 45 taken 31 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 31 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 31 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 38 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 69 times.
✓ Branch 54 taken 38 times.
✓ Branch 55 taken 69 times.
✓ Branch 56 taken 38 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 69 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 69 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 69 times.
✓ Branch 63 taken 38 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 38 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 38 times.
✗ Branch 68 not taken.
|
383 | ] |
| 275 |
16/26✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 38 times.
✓ Branch 15 taken 31 times.
✓ Branch 16 taken 38 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 38 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 38 times.
✓ Branch 22 taken 69 times.
✓ Branch 23 taken 38 times.
✓ Branch 24 taken 38 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 38 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 38 times.
✓ Branch 30 taken 69 times.
✓ Branch 31 taken 38 times.
|
207 | names = [ names, attr_name ] |
| 276 | |||
| 277 | end if | ||
| 278 | end do read_loop | ||
| 279 | |||
| 280 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if(present(iline)) iline = iline + iline_ |
| 281 | |||
| 282 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | end function read_activation_attributes |
| 283 | !############################################################################### | ||
| 284 | |||
| 285 | |||
| 286 | !############################################################################### | ||
| 287 | 15 | function read_activation(unit, iline) result(activation) | |
| 288 | !! Read activation function from input file | ||
| 289 | implicit none | ||
| 290 | |||
| 291 | ! Arguments | ||
| 292 | integer, intent(in) :: unit | ||
| 293 | !! Unit number for input file | ||
| 294 | integer, intent(inout), optional :: iline | ||
| 295 | !! Line number | ||
| 296 | |||
| 297 | class(base_actv_type), allocatable :: activation | ||
| 298 | !! Activation function object | ||
| 299 | |||
| 300 | ! Local variables | ||
| 301 | 15 | type(onnx_attribute_type), allocatable, dimension(:) :: attributes | |
| 302 | !! Array of ONNX attributes | ||
| 303 | integer :: i | ||
| 304 | !! Loop variable | ||
| 305 | character(20) :: actv_name | ||
| 306 | !! Activation function name | ||
| 307 | logical :: found | ||
| 308 | !! Flag for finding activation creator | ||
| 309 | integer :: creator_index | ||
| 310 | !! Index of activation creator | ||
| 311 | integer :: iline_ = 0 | ||
| 312 | !! Line number | ||
| 313 | |||
| 314 | ! initialise list if needed | ||
| 315 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
|
15 | if(.not.allocated(list_of_onnx_activation_creators)) & |
| 316 | 14 | call allocate_list_of_onnx_activation_creators() | |
| 317 | |||
| 318 | ! Read activation attributes | ||
| 319 |
11/34✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 38 times.
✓ Branch 12 taken 15 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 38 times.
✓ Branch 28 taken 15 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 38 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 38 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 38 times.
|
106 | attributes = read_activation_attributes(unit, iline=iline_) |
| 320 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if(present(iline)) iline = iline + iline_ |
| 321 | |||
| 322 | ! Extract activation name | ||
| 323 | 15 | actv_name = "" | |
| 324 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | do i=1, size(attributes,dim=1) |
| 325 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15 times.
✗ Branch 10 not taken.
|
30 | if(trim(to_lower(attributes(i)%name)) .eq. "name")then |
| 326 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
|
15 | actv_name = trim(to_lower(attributes(i)%val)) |
| 327 | 30 | exit | |
| 328 | end if | ||
| 329 | end do | ||
| 330 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if(actv_name .eq. "")then |
| 331 | call stop_program( & | ||
| 332 | "Activation name '"// actv_name //"' not specified in activation block" & | ||
| 333 | ✗ | ) | |
| 334 | ✗ | return | |
| 335 | end if | ||
| 336 |
1/2✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
|
117 | do i = 1, size(list_of_onnx_activation_creators,dim=1) |
| 337 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✓ Branch 7 taken 117 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 102 times.
|
234 | if(trim(to_lower(list_of_onnx_activation_creators(i)%name)) .eq. actv_name)then |
| 338 | 15 | found = .true. | |
| 339 | 15 | creator_index = i | |
| 340 | 132 | exit | |
| 341 | end if | ||
| 342 | end do | ||
| 343 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if(.not.found)then |
| 344 | call stop_program( & | ||
| 345 | "Activation name '"// actv_name //"' not recognised" & | ||
| 346 | ✗ | ) | |
| 347 | ✗ | return | |
| 348 | end if | ||
| 349 | ✗ | allocate(activation, source = list_of_onnx_activation_creators(creator_index)% & | |
| 350 |
4/8✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
✓ Branch 9 taken 15 times.
✗ Branch 10 not taken.
|
30 | create_ptr(attributes)) |
| 351 | |||
| 352 |
7/12✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 38 times.
✗ Branch 12 not taken.
|
68 | end function read_activation |
| 353 | !############################################################################### | ||
| 354 | |||
| 355 |
3/5✓ Branch 0 taken 255 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
|
286 | end module athena__activation |
| 356 |