Skip to content

Commit edf8533

Browse files
committed
Merge branch 'main' into delete-caf-macro
2 parents 1acb099 + 65d74e9 commit edf8533

7 files changed

+47
-20
lines changed

CMakeLists.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,23 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES Cray)
7878
endif()
7979

8080
# library to archive (libneural.a)
81-
add_library(neural src/mod_activation.f90 src/mod_io.f90 src/mod_kinds.f90 src/mod_layer.f90 src/mod_mnist.f90 src/mod_network.f90 src/mod_parallel.f90 src/mod_random.f90)
81+
add_library(neural
82+
src/mod_activation.f90
83+
src/mod_activation_submodule.f90
84+
src/mod_io.f90
85+
src/mod_io_submodule.f90
86+
src/mod_kinds.f90
87+
src/mod_layer.f90
88+
src/mod_layer_submodule.f90
89+
src/mod_mnist.f90
90+
src/mod_mnist_submodule.f90
91+
src/mod_network.f90
92+
src/mod_network_submodule.f90
93+
src/mod_parallel.f90
94+
src/mod_parallel_submodule.f90
95+
src/mod_random.f90
96+
src/mod_random_submodule.f90
97+
)
8298

8399
# Remove leading or trailing whitespace
84100
string(REGEX REPLACE "^ | $" "" LIBS "${LIBS}")

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Dependencies:
4343
* OpenCoarrays (optional, for parallel execution, GFortran only)
4444
* BLAS, MKL (optional)
4545

46+
Compilers tested include:
47+
48+
* gfortran-10.3.0
49+
* ifort-2021.4
50+
* ifx-2021.4
51+
4652
### Building with fpm
4753

4854
#### Building in serial mode

fpm.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "neural-fortran"
2-
version = "0.1.0"
2+
version = "0.2.0"
33
license = "MIT"
44
author = "Milan Curcic"
55
maintainer = "[email protected]"
6-
copyright = "Copyright 2018-2021, neural-fortran contributors"
6+
copyright = "Copyright 2018-2022, neural-fortran contributors"

src/mod_layer.f90

+12-9
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,30 @@ module mod_layer
3131
end type array2d
3232

3333
interface layer_type
34-
type(layer_type) module function constructor(this_size, next_size) result(layer)
35-
!! Layer class constructor. this_size is the number of neurons in the layer.
36-
!! next_size is the number of neurons in the next layer, used to allocate
37-
!! the weights.
38-
implicit none
39-
integer(ik), intent(in) :: this_size, next_size
40-
end function constructor
34+
module function constructor(this_size, next_size) result(layer)
35+
!! Layer class constructor. this_size is the number of neurons in the layer.
36+
!! next_size is the number of neurons in the next layer, used to allocate
37+
!! the weights.
38+
implicit none
39+
integer(ik), intent(in) :: this_size, next_size
40+
type(layer_type) layer
41+
end function constructor
4142
end interface layer_type
4243

4344
interface array1d
44-
pure type(array1d) module function array1d_constructor(length) result(a)
45+
pure module function array1d_constructor(length) result(a)
4546
!! Overloads the default type constructor.
4647
implicit none
4748
integer(ik), intent(in) :: length
49+
type(array1d) :: a
4850
end function array1d_constructor
4951
end interface array1d
5052

5153
interface array2d
52-
pure type(array2d) module function array2d_constructor(dims) result(a)
54+
pure module function array2d_constructor(dims) result(a)
5355
!! Overloads the default type constructor.
5456
integer(ik), intent(in) :: dims(2)
57+
type(array2d) :: a
5558
end function array2d_constructor
5659
end interface array2d
5760

src/mod_layer_submodule.f90

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
contains
88

9-
type(layer_type) module function constructor(this_size, next_size) result(layer)
9+
module function constructor(this_size, next_size) result(layer)
1010
integer(ik), intent(in) :: this_size, next_size
11+
type(layer_type) :: layer
1112
allocate(layer % a(this_size))
1213
allocate(layer % z(this_size))
1314
layer % a = 0
@@ -16,14 +17,16 @@ type(layer_type) module function constructor(this_size, next_size) result(layer)
1617
layer % b = randn(this_size)
1718
end function constructor
1819

19-
pure type(array1d) module function array1d_constructor(length) result(a)
20+
pure module function array1d_constructor(length) result(a)
2021
integer(ik), intent(in) :: length
22+
type(array1d) :: a
2123
allocate(a % array(length))
2224
a % array = 0
2325
end function array1d_constructor
2426

25-
pure type(array2d) module function array2d_constructor(dims) result(a)
27+
pure module function array2d_constructor(dims) result(a)
2628
integer(ik), intent(in) :: dims(2)
29+
type(array2d) :: a
2730
allocate(a % array(dims(1), dims(2)))
2831
a % array = 0
2932
end function array2d_constructor

src/mod_network.f90

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ module mod_network
4040

4141
interface network_type
4242

43-
type(network_type) module function net_constructor(dims, activation) result(net)
43+
module function net_constructor(dims, activation) result(net)
4444
!! Network class constructor. Size of input array dims indicates the total
4545
!! number of layers (input + hidden + output), and the value of its elements
4646
!! corresponds the size of each layer.
4747
implicit none
4848
integer(ik), intent(in) :: dims(:)
4949
character(len=*), intent(in), optional :: activation
50+
type(network_type) :: net
5051
end function net_constructor
5152

5253
end interface network_type
@@ -62,7 +63,6 @@ pure real(rk) module function accuracy(self, x, y)
6263
real(rk), intent(in) :: x(:,:), y(:,:)
6364
end function accuracy
6465

65-
6666
pure module subroutine backprop(self, y, dw, db)
6767
!! Applies a backward propagation through the network
6868
!! and returns the weight and bias gradients.
@@ -82,7 +82,6 @@ pure module subroutine fwdprop(self, x)
8282
real(rk), intent(in) :: x(:)
8383
end subroutine fwdprop
8484

85-
8685
module subroutine init(self, dims)
8786
!! Allocates and initializes the layers with given dimensions dims.
8887
implicit none

src/mod_network_submodule.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
contains
1010

11-
type(network_type) module function net_constructor(dims, activation) result(net)
11+
module function net_constructor(dims, activation) result(net)
1212
integer(ik), intent(in) :: dims(:)
1313
character(len=*), intent(in), optional :: activation
14+
type(network_type) :: net
1415
call net % init(dims)
1516
if (present(activation)) then
1617
call net % set_activation(activation)
@@ -20,7 +21,6 @@ type(network_type) module function net_constructor(dims, activation) result(net)
2021
call net % sync(1)
2122
end function net_constructor
2223

23-
2424
pure real(rk) module function accuracy(self, x, y)
2525
class(network_type), intent(in) :: self
2626
real(rk), intent(in) :: x(:,:), y(:,:)

0 commit comments

Comments
 (0)