Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest]
os: [macOS-12]
fail-fast: true
env:
FC: gfortran
GCC_V: 13
GCC_V: 14

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Dependencies MacOS
if: contains(matrix.os, 'mac')
run: |
brew install gcc@${GCC_V}
sudo ln -s $(which gfortran-${GCC_V}) $(dirname $(which gfortran-${GCC_V}))/gfortran
Expand Down
47 changes: 18 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,54 +48,41 @@ The available optimizers for training neural networks are
1. Stochastic gradient descent
2. Adam (recommended)

Prerequisite
------------
Building Inference-Engine requires a Fortran 2018 compiler. With `gfortran`, the required minimum compiler version is 13.

Building and Testing
--------------------
Build and Test
--------------
With the [Fortran Package Manager] (`fpm`) and a recent version of a Fortran compiler installed, enter one of the commmands below to build the Inference-Engine library and run the test suite:

### GNU (`gfortran`)
#### macOS
To build, and test Inference-Engine with `gfortran` in your `PATH` and your present working directory set to your
local copy of the `inference-engine` repository, enter the following commands in macOS Terminal window
(using the default `zsh` shell or `bash`):
```
./setup.sh
```
whereupon the trailing output will provide instructions for running the codes in the [example](./example) subdirectory.

#### Linux (including the Windows Subsystem for Linux)
The above `setup.sh` script assumes that you have either have `fpm` installed and or that the script can use Homebrew
to install it. If neither is true, please [install `fpm`] and then build and test Inference-Engine with the
following command:
```
fpm test
```

### Intel (`ifx`) -- under development
As of this writing, `ifx` compiles all of Inference-Engine and all tests pass except tests involving training.
We are working with Intel on supporting training with `ifx`. If you would like to build Inference-Engine and
run the tests, please execute the following command
### Intel (`ifx`)
```
fpm test --compiler ifx --flag "-coarray -coarray-num-images=1"
fpm test --compiler ifx
```

#### _Experimental:_ Automatic offloading of `do concurrent` to GPUs
This capability is under development with the goal to facilitate GPU automatic offloading via the following command:
```
fpm test --compiler ifx --flag "-coarray -coarray-num-images=1 -fopenmp-target-do-concurrent -qopenmp -fopenmp-targets=spir64"
fpm test --compiler ifx --flag "-fopenmp-target-do-concurrent -qopenmp -fopenmp-targets=spir64"
```

### LLVM (`flang-new`)
Support for LLVM `flang-new` is under development and currently requires building `flang-new` from source with assumed-rank support enabled:
```
fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank"
```
A script that might help with building `flang-new` from source is in the [handy-dandy] repository.


### NAG (`nagfor`) -- under development
As of this writing, `nagfor` compiles all of Inference-Engine and passes only tests that involve neither inference nor training.
We are working with NAG on supporting inference and training with `nagfor`.
```
fpm test --compiler nagfor --flag "-fpp -f2018 -coarray=single"
fpm test --compiler nagfor --flag -fpp
```

### HPE (`crayftn.sh`) -- under development
As of this writing, the Cray Compiler Environment (CCE) Fortran compiler does not build Inference-Engine.
Support for the Cray Compiler Environment (CCE) Fortran compiler is under development.
Building with the CCE `ftn` compiler wrapper requires an additional trivial wrapper.
With a shell script named `crayftn.sh` of the following form in your `PATH`
```
Expand Down Expand Up @@ -146,3 +133,5 @@ Please see the Inference-Engine GitHub Pages [site] for HTML documentation gener
[sourcery]: https://github.com/sourceryinstitute/sourcery
[rojff]: https://gitlab.com/everythingfunctional/rojff
[install `fpm`]: https://fpm.fortran-lang.org/install/index.html#install
[Fortran Package Manager]: https://github.com/fortran-lang/fpm
[handy-dandy]: https://github.com/rouson/handy-dandy/blob/main/src/fresh-llvm-build.sh
2 changes: 1 addition & 1 deletion example/concurrent-inferences.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ program concurrent_inferences
!! This program demonstrates how to read a neural network from a JSON file
!! and use the network to perform concurrent inferences.
use inference_engine_m, only : inference_engine_t, tensor_t, infer
use sourcery_m, only : string_t, command_line_t, file_t
use julienne_m, only : string_t, command_line_t, file_t
use assert_m, only : assert
use iso_fortran_env, only : int64, real64
implicit none
Expand Down
7 changes: 4 additions & 3 deletions example/learn-addition.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program learn_addition
!! This trains a neural network to learn the following six polynomial functions of its eight inputs.
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t
use julienne_m, only : string_t, file_t, command_line_t, bin_t
use assert_m, only : assert, intrinsic_array_t
use addition_m, only : y
implicit none
Expand Down Expand Up @@ -84,7 +84,7 @@ program learn_addition
block
real, parameter :: tolerance = 1.E-06
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -94,7 +94,8 @@ program learn_addition
do p = 1, num_pairs
print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block
Expand Down
7 changes: 4 additions & 3 deletions example/learn-exponentiation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program learn_exponentiation
!! This trains a neural network to learn the following six polynomial functions of its eight inputs.
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t
use julienne_m, only : string_t, file_t, command_line_t, bin_t
use assert_m, only : assert, intrinsic_array_t
use exponentiation_m, only : y
implicit none
Expand Down Expand Up @@ -84,7 +84,7 @@ program learn_exponentiation
block
real, parameter :: tolerance = 1.E-06
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -94,7 +94,8 @@ program learn_exponentiation
do p = 1, num_pairs
print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block
Expand Down
7 changes: 4 additions & 3 deletions example/learn-microphysics-procedures.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ program learn_microphysics_procedures
!! in of ICAR (https://github.com/BerkeleyLab/icar).
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, sigmoid_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t, csv
use julienne_m, only : string_t, file_t, command_line_t, bin_t, csv
use assert_m, only : assert, intrinsic_array_t
use thompson_tensors_m, only : y, T, p
use iso_fortran_env, only : int64, output_unit
Expand Down Expand Up @@ -120,7 +120,7 @@ program learn_microphysics_procedures
report_network_performance: &
block
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -130,7 +130,8 @@ program learn_microphysics_procedures
do p = 1, num_pairs
print "(6(G13.5,2x))", inputs(p)%values(), network_outputs(p)%values(), desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block report_network_performance
Expand Down
7 changes: 4 additions & 3 deletions example/learn-multiplication.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program learn_multiplication
!! This trains a neural network to learn the following six polynomial functions of its eight inputs.
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t
use julienne_m, only : string_t, file_t, command_line_t, bin_t
use assert_m, only : assert, intrinsic_array_t
use multiply_inputs, only : y
implicit none
Expand Down Expand Up @@ -84,7 +84,7 @@ program learn_multiplication
block
real, parameter :: tolerance = 1.E-06
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -94,7 +94,8 @@ program learn_multiplication
do p = 1, num_pairs
print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block
Expand Down
7 changes: 4 additions & 3 deletions example/learn-power-series.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program learn_power_series
!! This trains a neural network to learn the following six polynomial functions of its eight inputs.
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t
use julienne_m, only : string_t, file_t, command_line_t, bin_t
use assert_m, only : assert, intrinsic_array_t
use power_series, only : y
implicit none
Expand Down Expand Up @@ -86,7 +86,7 @@ program learn_power_series
block
real, parameter :: tolerance = 1.E-06
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -96,7 +96,8 @@ program learn_power_series
do p = 1, num_pairs
print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block
Expand Down
7 changes: 4 additions & 3 deletions example/learn-saturated-mixing-ratio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ program train_saturated_mixture_ratio
!! This program trains a neural network to learn the saturated mixing ratio function of ICAR.
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t, csv
use julienne_m, only : string_t, file_t, command_line_t, bin_t, csv
use assert_m, only : assert, intrinsic_array_t
use saturated_mixing_ratio_m, only : y, T, p
use iso_fortran_env, only : int64, output_unit
Expand Down Expand Up @@ -119,7 +119,7 @@ program train_saturated_mixture_ratio
report_network_performance: &
block
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -129,7 +129,8 @@ program train_saturated_mixture_ratio
do p = 1, num_pairs
print "(4(G13.5,2x))", inputs(p)%values(), network_outputs(p)%values(), desired_outputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block report_network_performance
Expand Down
2 changes: 1 addition & 1 deletion example/print-training-configuration.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
program print_training_configuration
!! Demonstrate how to construct and print a training_configuration_t object
use inference_engine_m, only : training_configuration_t, hyperparameters_t, network_configuration_t
use sourcery_m, only : file_t
use julienne_m, only : file_t
implicit none
#ifdef _CRAYFTN
type(training_configuration_t) :: training_configuration
Expand Down
7 changes: 4 additions & 3 deletions example/train-and-write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ program train_and_write
!! that is uniformly distributed on the range [0,0.1].
use inference_engine_m, only : &
inference_engine_t, trainable_engine_t, mini_batch_t, tensor_t, input_output_pair_t, shuffle, relu_t
use sourcery_m, only : string_t, file_t, command_line_t, bin_t
use julienne_m, only : string_t, file_t, command_line_t, bin_t
use assert_m, only : assert, intrinsic_array_t
implicit none

Expand Down Expand Up @@ -72,7 +72,7 @@ program train_and_write
block
real, parameter :: tolerance = 1.E-06
integer p
#ifdef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
type(tensor_t), allocatable :: network_outputs(:)
network_outputs = trainable_engine%infer(inputs)
#else
Expand All @@ -84,7 +84,8 @@ program train_and_write
do p = 1, num_pairs
print *,network_outputs(p)%values(),"|", inputs(p)%values(), "|", network_outputs(p)%values() - inputs(p)%values()
end do
#ifndef _CRAYFTN
#if defined _CRAYFTN || __GFORTRAN__
#else
end associate
#endif
end block
Expand Down
2 changes: 1 addition & 1 deletion example/write-read-infer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ program write_read_infer
!! non-negative inputs to the corresponding outputs using a RELU activation
!! function.
use inference_engine_m, only : inference_engine_t, relu_t, tensor_t
use sourcery_m, only : string_t, command_line_t, file_t
use julienne_m, only : string_t, command_line_t, file_t
use kind_parameters_m, only : rkind
implicit none

Expand Down
4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ author = "Damian Rouson, Tan Nguyen, Jordan Welsman, David Torres, Brad Richards
maintainer = "rouson@lbl.gov"

[dependencies]
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.6.0"}
sourcery = {git = "https://github.com/sourceryinstitute/sourcery", tag = "4.8.1"}
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.7.0"}
julienne = {git = "https://github.com/sourceryinstitute/julienne", tag = "2ca5c93e11b46395608fd00abbdf797d9be0b3d4"}
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ if ! command -v fpm > /dev/null ; then
fi
fi

FPM_FC=${FC:-"gfortran-13"}
FPM_CC=${CC:-"gcc-13"}
FPM_FC=${FC:-"gfortran-14"}
FPM_CC=${CC:-"gcc-14"}

fpm test --profile release --flag "-fopenmp"

Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/activation_strategy_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module activation_strategy_m

! External dependencies
use kind_parameters_m, only : rkind
use sourcery_string_m, only : string_t
use julienne_string_m, only : string_t
implicit none

private
Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/hyperparameters_m.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module hyperparameters_m
use sourcery_string_m, only : string_t
use julienne_string_m, only : string_t
use kind_parameters_m, only : rkind
implicit none

Expand Down
4 changes: 2 additions & 2 deletions src/inference_engine/inference_engine_m_.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module inference_engine_m_
!! Define an abstraction that supports inference operationsn on a neural network
use activation_strategy_m, only : activation_strategy_t
use sourcery_file_m, only : file_t
use sourcery_string_m, only : string_t
use julienne_file_m, only : file_t
use julienne_string_m, only : string_t
use kind_parameters_m, only : rkind
use tensor_m, only : tensor_t
use tensor_range_m, only : tensor_range_t
Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/inference_engine_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use relu_m, only : relu_t
use layer_m, only : layer_t
use neuron_m, only : neuron_t
use sourcery_formats_m, only : separated_values
use julienne_formats_m, only : separated_values
implicit none

interface assert_consistency
Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/layer_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
! Terms of use are as specified in LICENSE.txt
module layer_m
use neuron_m, only : neuron_t
use sourcery_string_m, only : string_t
use julienne_string_m, only : string_t
use kind_parameters_m, only : rkind
use inference_engine_m_, only : inference_engine_t
use tensor_range_m, only : tensor_range_t
Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/network_configuration_m.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module network_configuration_m
use sourcery_string_m, only : string_t
use julienne_string_m, only : string_t
implicit none

private
Expand Down
2 changes: 1 addition & 1 deletion src/inference_engine/network_configuration_s.F90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
submodule(network_configuration_m) network_configuration_s
use assert_m, only : assert
use sourcery_formats_m, only : csv
use julienne_formats_m, only : csv
implicit none

character(len=*), parameter :: skip_connections_key = "skip connections"
Expand Down
Loading