| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module athena__pad1d_layer | ||
| 2 | !! Module containing implementation of a 1D padding layer | ||
| 3 | !! | ||
| 4 | !! This module implements padding for 1D sequential data, adding values | ||
| 5 | !! at the boundaries to control output dimensions or prepare for convolution. | ||
| 6 | !! | ||
| 7 | !! Operation: Extends sequence at boundaries | ||
| 8 | !! input: [x1, x2, ..., xn] | ||
| 9 | !! output: [p_left copies] + [x1, x2, ..., xn] + [p_right copies] | ||
| 10 | !! | ||
| 11 | !! Padding modes: | ||
| 12 | !! - 'constant': pad with fixed value (typically 0) | ||
| 13 | !! - 'replicate': repeat edge values | ||
| 14 | !! - 'reflect': mirror values at boundaries | ||
| 15 | !! | ||
| 16 | !! Common use: Preserve spatial dimensions through convolution | ||
| 17 | !! Shape: (length, channels) -> (length + p_left + p_right, channels) | ||
| 18 | use coreutils, only: real32, stop_program | ||
| 19 | use athena__base_layer, only: pad_layer_type, base_layer_type | ||
| 20 | use diffstruc, only: array_type | ||
| 21 | use athena__diffstruc_extd, only: pad1d | ||
| 22 | use athena__misc_types, only: & | ||
| 23 | onnx_node_type, onnx_initialiser_type, onnx_tensor_type | ||
| 24 | implicit none | ||
| 25 | |||
| 26 | |||
| 27 | private | ||
| 28 | |||
| 29 | public :: pad1d_layer_type | ||
| 30 | public :: read_pad1d_layer | ||
| 31 | |||
| 32 | |||
| 33 | type, extends(pad_layer_type) :: pad1d_layer_type | ||
| 34 | !! Type for 1D padding layer with overloaded procedures | ||
| 35 | contains | ||
| 36 | procedure, pass(this) :: set_hyperparams => set_hyperparams_pad1d | ||
| 37 | !! Set hyperparameters for 1D padding layer | ||
| 38 | procedure, pass(this) :: read => read_pad1d | ||
| 39 | !! Read 1D padding layer from file | ||
| 40 | |||
| 41 | procedure, pass(this) :: forward => forward_pad1d | ||
| 42 | !! Forward propagation derived type handler | ||
| 43 | |||
| 44 | end type pad1d_layer_type | ||
| 45 | |||
| 46 | interface pad1d_layer_type | ||
| 47 | !! Interface for setting up the 1D padding layer | ||
| 48 | module function layer_setup( & | ||
| 49 | padding, method, & | ||
| 50 | input_shape, & | ||
| 51 | verbose & | ||
| 52 | ) result(layer) | ||
| 53 | !! Set up the 1D padding layer | ||
| 54 | integer, dimension(:), intent(in) :: padding | ||
| 55 | !! Padding sizes | ||
| 56 | character(*), intent(in) :: method | ||
| 57 | !! Padding method | ||
| 58 | integer, dimension(:), optional, intent(in) :: input_shape | ||
| 59 | !! Input shape | ||
| 60 | integer, optional, intent(in) :: verbose | ||
| 61 | !! Verbosity level | ||
| 62 | type(pad1d_layer_type) :: layer | ||
| 63 | !! Instance of the 1D padding layer | ||
| 64 | end function layer_setup | ||
| 65 | end interface pad1d_layer_type | ||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | contains | ||
| 70 | |||
| 71 | !############################################################################### | ||
| 72 | 16 | module function layer_setup( & | |
| 73 | 16 | padding, method, & | |
| 74 |
4/6✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
|
16 | input_shape, & |
| 75 | verbose & | ||
| 76 | 16 | ) result(layer) | |
| 77 | !! Set up the 1D padding layer | ||
| 78 | implicit none | ||
| 79 | |||
| 80 | ! Arguments | ||
| 81 | integer, dimension(:), intent(in) :: padding | ||
| 82 | !! Padding sizes | ||
| 83 | character(*), intent(in) :: method | ||
| 84 | !! Padding method | ||
| 85 | integer, dimension(:), optional, intent(in) :: input_shape | ||
| 86 | !! Input shape | ||
| 87 | integer, optional, intent(in) :: verbose | ||
| 88 | !! Verbosity level | ||
| 89 | |||
| 90 | type(pad1d_layer_type) :: layer | ||
| 91 | !! Instance of the 1D padding layer | ||
| 92 | |||
| 93 | ! Local variables | ||
| 94 | integer :: verbose_ = 0 | ||
| 95 | !! Verbosity level | ||
| 96 | integer, dimension(1) :: padding_1d | ||
| 97 | !! 1D padding sizes | ||
| 98 | |||
| 99 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if(present(verbose)) verbose_ = verbose |
| 100 | |||
| 101 | !--------------------------------------------------------------------------- | ||
| 102 | ! Initialise padding sizes | ||
| 103 | !--------------------------------------------------------------------------- | ||
| 104 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
|
16 | select case(size(padding)) |
| 105 | case(1) | ||
| 106 |
6/10✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
|
32 | padding_1d = padding |
| 107 | case default | ||
| 108 | ✗ | write(*,*) size(padding) | |
| 109 | ✗ | write(*,*) padding | |
| 110 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | call stop_program("Invalid padding size") |
| 111 | end select | ||
| 112 | |||
| 113 | |||
| 114 | !--------------------------------------------------------------------------- | ||
| 115 | ! Set hyperparameters | ||
| 116 | !--------------------------------------------------------------------------- | ||
| 117 | 16 | call layer%set_hyperparams(padding=padding_1d, method=method, verbose=verbose_) | |
| 118 | |||
| 119 | |||
| 120 | !--------------------------------------------------------------------------- | ||
| 121 | ! Initialise layer shape | ||
| 122 | !--------------------------------------------------------------------------- | ||
| 123 |
6/10✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 13 times.
|
16 | if(present(input_shape)) call layer%init(input_shape=input_shape) |
| 124 | |||
| 125 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
32 | end function layer_setup |
| 126 | !############################################################################### | ||
| 127 | |||
| 128 | |||
| 129 | !############################################################################### | ||
| 130 | 17 | subroutine set_hyperparams_pad1d(this, padding, method, verbose) | |
| 131 | !! Set hyperparameters for 1D padding layer | ||
| 132 | use coreutils, only: to_lower | ||
| 133 | implicit none | ||
| 134 | |||
| 135 | ! Arguments | ||
| 136 | class(pad1d_layer_type), intent(inout) :: this | ||
| 137 | !! Instance of the 1D padding layer | ||
| 138 | integer, dimension(1), intent(in) :: padding | ||
| 139 | !! Padding sizes | ||
| 140 | character(*), intent(in) :: method | ||
| 141 | !! Padding method | ||
| 142 | integer, optional, intent(in) :: verbose | ||
| 143 | !! Verbosity level | ||
| 144 | |||
| 145 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
|
17 | this%name = "pad1d" |
| 146 | 17 | this%type = "pad" | |
| 147 | 17 | this%input_rank = 2 | |
| 148 | 17 | this%output_rank = 2 | |
| 149 |
6/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✓ Branch 7 taken 17 times.
|
35 | this%pad = padding |
| 150 |
9/14✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
19 | if(allocated(this%facets)) deallocate(this%facets) |
| 151 |
18/34✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 17 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 17 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 17 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 17 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 17 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 17 times.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 17 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 17 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 17 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 17 times.
|
34 | allocate(this%facets(this%input_rank - 1)) |
| 152 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
|
17 | this%facets(1)%rank = 1 |
| 153 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
|
17 | this%facets(1)%nfixed_dims = 1 |
| 154 | 34 | select case(trim(adjustl(to_lower(method)))) | |
| 155 | case("valid", "none") | ||
| 156 | 2 | this%imethod = 0 | |
| 157 | case("same", "zero", "constant", "const") | ||
| 158 | 11 | this%imethod = 1 | |
| 159 | case("full") | ||
| 160 | 1 | this%imethod = 2 | |
| 161 | case("circular", "circ") | ||
| 162 | 1 | this%imethod = 3 | |
| 163 | case("reflection", "reflect", "refl") | ||
| 164 | 1 | this%imethod = 4 | |
| 165 | case("replication", "replicate", "copy", "repl") | ||
| 166 | 1 | this%imethod = 5 | |
| 167 | case default | ||
| 168 | ✗ | call stop_program("Unrecognised padding method :"//method) | |
| 169 |
7/9✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
51 | return |
| 170 | end select | ||
| 171 |
2/4✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
|
17 | this%method = trim(adjustl(to_lower(method))) |
| 172 | |||
| 173 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
|
17 | end subroutine set_hyperparams_pad1d |
| 174 | !############################################################################### | ||
| 175 | |||
| 176 | |||
| 177 | !##############################################################################! | ||
| 178 | ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! | ||
| 179 | !##############################################################################! | ||
| 180 | |||
| 181 | |||
| 182 | !############################################################################### | ||
| 183 | 1 | subroutine read_pad1d(this, unit, verbose) | |
| 184 | !! Read 1D padding layer from file | ||
| 185 | use athena__tools_infile, only: assign_val, assign_vec | ||
| 186 | use coreutils, only: to_lower, to_upper, icount | ||
| 187 | implicit none | ||
| 188 | |||
| 189 | ! Arguments | ||
| 190 | class(pad1d_layer_type), intent(inout) :: this | ||
| 191 | !! Instance of the 1D padding layer | ||
| 192 | integer, intent(in) :: unit | ||
| 193 | !! File unit | ||
| 194 | integer, optional, intent(in) :: verbose | ||
| 195 | !! Verbosity level | ||
| 196 | |||
| 197 | ! Local variables | ||
| 198 | integer :: verbose_ = 0 | ||
| 199 | !! Verbosity level | ||
| 200 | integer :: stat | ||
| 201 | !! File status | ||
| 202 | integer :: itmp1 | ||
| 203 | integer, dimension(1) :: padding | ||
| 204 | !! Padding sizes | ||
| 205 | integer, dimension(2) :: input_shape | ||
| 206 | !! Input shape | ||
| 207 | character(20) :: method | ||
| 208 | !! Padding method | ||
| 209 | character(256) :: buffer, tag, err_msg | ||
| 210 | !! Buffer for reading lines, tag for identifying lines, error message | ||
| 211 | |||
| 212 | |||
| 213 | ! Initialise optional arguments | ||
| 214 | !--------------------------------------------------------------------------- | ||
| 215 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(present(verbose)) verbose_ = verbose |
| 216 | |||
| 217 | |||
| 218 | ! Loop over tags in layer card | ||
| 219 | !--------------------------------------------------------------------------- | ||
| 220 | 3 | tag_loop: do | |
| 221 | |||
| 222 | ! Check for end of file | ||
| 223 | !------------------------------------------------------------------------ | ||
| 224 | 4 | read(unit,'(A)',iostat=stat) buffer | |
| 225 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(stat.ne.0)then |
| 226 | write(err_msg,'("file encountered error (EoF?) before END ",A)') & | ||
| 227 | ✗ | to_upper(this%name) | |
| 228 | ✗ | call stop_program(err_msg) | |
| 229 | ✗ | return | |
| 230 | end if | ||
| 231 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
4 | if(trim(adjustl(buffer)).eq."") cycle tag_loop |
| 232 | |||
| 233 | ! Check for end of layer card | ||
| 234 | !------------------------------------------------------------------------ | ||
| 235 |
4/6✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3 times.
|
8 | if(trim(adjustl(buffer)).eq."END "//to_upper(trim(this%name)))then |
| 236 | 1 | backspace(unit) | |
| 237 | 4 | exit tag_loop | |
| 238 | end if | ||
| 239 | |||
| 240 |
2/4✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | tag=trim(adjustl(buffer)) |
| 241 |
5/10✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
3 | if(scan(buffer,"=").ne.0) tag=trim(tag(:scan(tag,"=")-1)) |
| 242 | |||
| 243 | ! Read parameters from save file | ||
| 244 | !------------------------------------------------------------------------ | ||
| 245 | 6 | select case(trim(tag)) | |
| 246 | case("INPUT_SHAPE") | ||
| 247 | 1 | call assign_vec(buffer, input_shape, itmp1) | |
| 248 | case("PADDING") | ||
| 249 | 1 | call assign_vec(buffer, padding, itmp1) | |
| 250 | case("METHOD") | ||
| 251 | 1 | call assign_val(buffer, method, itmp1) | |
| 252 | case default | ||
| 253 | ! Don't look for "e" due to scientific notation of numbers | ||
| 254 | ! ... i.e. exponent (E+00) | ||
| 255 | ✗ | if(scan(to_lower(trim(adjustl(buffer))),& | |
| 256 | 'abcdfghijklmnopqrstuvwxyz').eq.0)then | ||
| 257 | ✗ | cycle tag_loop | |
| 258 | ✗ | elseif(tag(:3).eq.'END')then | |
| 259 | ✗ | cycle tag_loop | |
| 260 | end if | ||
| 261 | write(err_msg,'("Unrecognised line in input file: ",A)') & | ||
| 262 | ✗ | trim(adjustl(buffer)) | |
| 263 | ✗ | call stop_program(err_msg) | |
| 264 |
4/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
6 | return |
| 265 | end select | ||
| 266 | end do tag_loop | ||
| 267 | |||
| 268 | |||
| 269 | ! Set hyperparameters and initialise layer | ||
| 270 | !--------------------------------------------------------------------------- | ||
| 271 | 1 | call this%set_hyperparams(padding=padding, method=method, verbose=verbose_) | |
| 272 | 1 | call this%init(input_shape = input_shape) | |
| 273 | |||
| 274 | |||
| 275 | ! Check for end of layer card | ||
| 276 | !--------------------------------------------------------------------------- | ||
| 277 | 1 | read(unit,'(A)') buffer | |
| 278 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
2 | if(trim(adjustl(buffer)).ne."END "//to_upper(trim(this%name)))then |
| 279 | ✗ | write(0,*) trim(adjustl(buffer)) | |
| 280 | ✗ | write(err_msg,'("END ",A," not where expected")') to_upper(this%name) | |
| 281 | ✗ | call stop_program(err_msg) | |
| 282 | 1 | return | |
| 283 | end if | ||
| 284 | |||
| 285 | end subroutine read_pad1d | ||
| 286 | !############################################################################### | ||
| 287 | |||
| 288 | |||
| 289 | !############################################################################### | ||
| 290 | 1 | function read_pad1d_layer(unit, verbose) result(layer) | |
| 291 | !! Read 1D padding layer from file and return layer | ||
| 292 | implicit none | ||
| 293 | |||
| 294 | ! Arguments | ||
| 295 | integer, intent(in) :: unit | ||
| 296 | !! File unit | ||
| 297 | integer, optional, intent(in) :: verbose | ||
| 298 | !! Verbosity level | ||
| 299 | class(base_layer_type), allocatable :: layer | ||
| 300 | !! Instance of the 1D padding layer | ||
| 301 | |||
| 302 | ! Local variables | ||
| 303 | integer :: verbose_ = 0 | ||
| 304 | !! Verbosity level | ||
| 305 | |||
| 306 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(present(verbose)) verbose_ = verbose |
| 307 |
18/70✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ 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 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 1 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 1 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 1 times.
✓ Branch 56 taken 1 times.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✓ Branch 59 taken 1 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 1 times.
✓ Branch 62 taken 1 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 1 times.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 1 times.
✗ Branch 70 not taken.
✓ Branch 71 taken 1 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 1 times.
|
4 | allocate(layer, source=pad1d_layer_type(padding=[0], method="none")) |
| 308 | 1 | call layer%read(unit, verbose=verbose_) | |
| 309 | |||
| 310 | 2 | end function read_pad1d_layer | |
| 311 | !############################################################################### | ||
| 312 | |||
| 313 | |||
| 314 | !############################################################################### | ||
| 315 | ✗ | subroutine build_from_onnx_pad1d( & | |
| 316 | ✗ | this, node, initialisers, value_info, verbose & | |
| 317 | ) | ||
| 318 | !! Read ONNX attributes for 1D padding layer | ||
| 319 | implicit none | ||
| 320 | |||
| 321 | ! Arguments | ||
| 322 | class(pad1d_layer_type), intent(inout) :: this | ||
| 323 | !! Instance of the 1D padding layer | ||
| 324 | type(onnx_node_type), intent(in) :: node | ||
| 325 | !! ONNX node information | ||
| 326 | type(onnx_initialiser_type), dimension(:), intent(in) :: initialisers | ||
| 327 | !! ONNX initialiser information | ||
| 328 | type(onnx_tensor_type), dimension(:), intent(in) :: value_info | ||
| 329 | !! ONNX value info | ||
| 330 | integer, intent(in) :: verbose | ||
| 331 | !! Verbosity level | ||
| 332 | |||
| 333 | ! Local variables | ||
| 334 | integer :: i | ||
| 335 | !! Loop index | ||
| 336 | integer, dimension(1) :: padding | ||
| 337 | !! Padding sizes | ||
| 338 | character(256) :: val, mode | ||
| 339 | !! Attribute value and mode | ||
| 340 | |||
| 341 | ! Set default values | ||
| 342 | ✗ | padding = 0 | |
| 343 | ✗ | mode = "constant" | |
| 344 | |||
| 345 | ! Parse ONNX attributes | ||
| 346 | ✗ | do i = 1, size(node%attributes) | |
| 347 | ✗ | val = node%attributes(i)%val | |
| 348 | ✗ | select case(trim(adjustl(node%attributes(i)%name))) | |
| 349 | case("pads") | ||
| 350 | ✗ | read(val,*) padding | |
| 351 | case("mode") | ||
| 352 | ✗ | mode = trim(adjustl(val)) | |
| 353 | case default | ||
| 354 | ! Do nothing | ||
| 355 | write(0,*) "WARNING: Unrecognised attribute in ONNX PAD1D & | ||
| 356 | ✗ | &layer: ", trim(adjustl(node%attributes(i)%name)) | |
| 357 | end select | ||
| 358 | end do | ||
| 359 | |||
| 360 | ! Check size of initialisers | ||
| 361 | ✗ | if(size(initialisers).gt.0)then | |
| 362 | ✗ | write(0,*) "WARNING: initialisers found for ONNX PAD1D layer" | |
| 363 | end if | ||
| 364 | |||
| 365 | call this%set_hyperparams( & | ||
| 366 | padding = padding, & | ||
| 367 | method = mode, & | ||
| 368 | verbose = verbose & | ||
| 369 | ✗ | ) | |
| 370 | |||
| 371 | ✗ | end subroutine build_from_onnx_pad1d | |
| 372 | !############################################################################### | ||
| 373 | |||
| 374 | |||
| 375 | !##############################################################################! | ||
| 376 | ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! | ||
| 377 | !##############################################################################! | ||
| 378 | |||
| 379 | |||
| 380 | !############################################################################### | ||
| 381 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | subroutine forward_pad1d(this, input) |
| 382 | !! Forward propagation | ||
| 383 | implicit none | ||
| 384 | |||
| 385 | ! Arguments | ||
| 386 | class(pad1d_layer_type), intent(inout) :: this | ||
| 387 | !! Instance of the 1D padding layer | ||
| 388 | class(array_type), dimension(:,:), intent(in) :: input | ||
| 389 | !! Input values | ||
| 390 | |||
| 391 | ! Local variables | ||
| 392 | type(array_type), pointer :: ptr | ||
| 393 | !! Pointer array | ||
| 394 | |||
| 395 | |||
| 396 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
|
13 | call this%output(1,1)%zero_grad() |
| 397 |
6/12✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13 times.
|
13 | ptr => pad1d(input(1,1), this%facets(1), this%pad(1), this%imethod) |
| 398 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
|
13 | call this%output(1,1)%assign_and_deallocate_source(ptr) |
| 399 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
|
13 | this%output(1,1)%is_temporary = .false. |
| 400 | |||
| 401 | 13 | end subroutine forward_pad1d | |
| 402 | !############################################################################### | ||
| 403 | |||
| 404 |
66/151✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ 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 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 times.
✓ Branch 37 taken 5 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 1 times.
✓ Branch 40 taken 5 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✓ Branch 43 taken 5 times.
✓ Branch 44 taken 1 times.
✓ Branch 45 taken 6 times.
✓ Branch 46 taken 5 times.
✓ Branch 47 taken 1 times.
✓ Branch 48 taken 10 times.
✓ Branch 49 taken 1 times.
✓ Branch 50 taken 5 times.
✓ Branch 51 taken 6 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 1 times.
✓ Branch 54 taken 5 times.
✓ Branch 55 taken 1 times.
✓ Branch 56 taken 5 times.
✓ Branch 57 taken 6 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 6 times.
✓ Branch 60 taken 6 times.
✓ Branch 61 taken 1 times.
✓ Branch 62 taken 5 times.
✓ Branch 63 taken 1 times.
✓ Branch 64 taken 5 times.
✓ Branch 65 taken 1 times.
✓ Branch 66 taken 5 times.
✓ Branch 67 taken 5 times.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✓ Branch 70 taken 5 times.
✓ Branch 71 taken 5 times.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✓ Branch 74 taken 5 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✓ Branch 109 taken 5 times.
✗ Branch 110 not taken.
✓ Branch 111 taken 5 times.
✗ Branch 112 not taken.
✓ Branch 113 taken 4 times.
✓ Branch 114 taken 1 times.
✓ Branch 115 taken 1 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 5 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 4 times.
✓ Branch 121 taken 1 times.
✓ Branch 122 taken 5 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 4 times.
✓ Branch 125 taken 1 times.
✓ Branch 126 taken 5 times.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✓ Branch 129 taken 5 times.
✓ Branch 130 taken 5 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 4 times.
✓ Branch 133 taken 1 times.
✓ Branch 134 taken 5 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 4 times.
✓ Branch 137 taken 1 times.
✓ Branch 138 taken 5 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 5 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 5 times.
✓ Branch 143 taken 5 times.
✓ Branch 144 taken 1 times.
✓ Branch 145 taken 4 times.
✓ Branch 146 taken 1 times.
✓ Branch 147 taken 4 times.
✓ Branch 148 taken 1 times.
✓ Branch 149 taken 4 times.
✗ Branch 150 not taken.
✓ Branch 151 taken 5 times.
|
58 | end module athena__pad1d_layer |
| 405 |