Skip to content

Commit 2ff343e

Browse files
committed
Don't transpose 4-d kernel; already stored correctly
1 parent 0268b26 commit 2ff343e

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/nf/io/nf_io_hdf5_submodule.f90

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,7 @@ module subroutine get_hdf5_dataset_real32_1d(filename, object_name, values)
5959
call f % open(filename, 'r')
6060
call f % shape(object_name, dims)
6161

62-
! If values is already allocated, re-allocate only if incorrect shape
63-
if (allocated(values)) then
64-
if (.not. all(shape(values) == dims)) then
65-
deallocate(values)
66-
allocate(values(dims(1)))
67-
end if
68-
else
69-
allocate(values(dims(1)))
70-
end if
62+
allocate(values(dims(1)))
7163

7264
call f % read(object_name, values)
7365
call f % close()
@@ -92,7 +84,7 @@ module subroutine get_hdf5_dataset_real32_2d(filename, object_name, values)
9284
call f % read(object_name, values)
9385
call f % close()
9486

95-
! Transpose the array to get from C to Fortran order
87+
! Transpose the array to respect Keras's storage order
9688
values = transpose(values)
9789

9890
end subroutine get_hdf5_dataset_real32_2d
@@ -115,13 +107,6 @@ module subroutine get_hdf5_dataset_real32_4d(filename, object_name, values)
115107
call f % read(object_name, values)
116108
call f % close()
117109

118-
! Transpose the array to get from C to Fortran order
119-
values = reshape( &
120-
values, &
121-
shape=[dims(4), dims(3), dims(2), dims(1)], &
122-
order=[4, 3, 2, 1] &
123-
)
124-
125110
end subroutine get_hdf5_dataset_real32_4d
126111

127112
end submodule nf_io_hdf5_submodule

test/test_io_hdf5.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ program test_io_hdf5
4242
write(stderr, '(a)') 'HDF5 1-d dataset dims inquiry is correct.. failed'
4343
end if
4444

45-
if (.not. all(shape(weights) == [30, 784])) then
45+
if (.not. all(shape(weights) == [784, 30])) then
4646
ok = .false.
4747
write(stderr, '(a)') 'HDF5 2-d dataset dims inquiry is correct.. failed'
4848
end if

0 commit comments

Comments
 (0)