Skip to content

Commit

Permalink
Make the library header only (#18)
Browse files Browse the repository at this point in the history
* Rename `include` as `headers`

* Rename `serial` folder as `nnhep`

* Fix relative paths in headers and small typo

* Add main header file

* Update include paths in main files

* Update include paths of test files
  • Loading branch information
sbaldu authored Nov 23, 2023
1 parent 5749959 commit ad2662c
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <string>
#include <sstream>

#include "serial/include/Activators.hpp"
#include "serial/include/ErrorFunction.hpp"
#include "serial/include/Network.hpp"
#include "nnhep.hpp"

int main(int argc, char** argv) {
double eta{0.975};
Expand Down
12 changes: 12 additions & 0 deletions src/nnhep.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#ifndef nnhep_hpp
#define nnhep_hpp

#include "nnhep/DataFormats/Matrix.hpp"
#include "nnhep/DataFormats/VectorOperations.hpp"
#include "nnhep/headers/Activators.hpp"
#include "nnhep/headers/ErrorFunction.hpp"
#include "nnhep/headers/Layer.hpp"
#include "nnhep/headers/Network.hpp"

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <memory>
#include <vector>

#include "DataFormats/Matrix.hpp"
#include "../DataFormats/Matrix.hpp"
#include "Layer.hpp"

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sstream>
#include <vector>

#include "DataFormats/Matrix.hpp"
#include "../DataFormats/Matrix.hpp"

/// @brief Layer of a neural network
/// @tparam T The type of the node values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "Activators.hpp"
#include "Layer.hpp"
#include "DataFormats/Matrix.hpp"
#include "DataFormats/VectorOperations.hpp"
#include "../DataFormats/Matrix.hpp"
#include "../DataFormats/VectorOperations.hpp"

template <typename T>
using shared = std::shared_ptr<T>;
Expand Down Expand Up @@ -176,7 +176,7 @@ template <typename T,
typename Activator,
template <typename E, typename LW, template <typename K> typename Act>
typename Loss>
Network<T, W, Activator, Loss>::Network(const std::vector<int>& nodes_per_layer)
Network<T, W, Activator, Loss>::Network(const std::vector<T>& nodes_per_layer)
: n_layers{static_cast<int>(nodes_per_layer.size())},
m_layers(n_layers + 1),
m_weights(n_layers + 1),
Expand Down
4 changes: 1 addition & 3 deletions src/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <string>
#include <sstream>

#include "serial/include/Activators.hpp"
#include "serial/include/ErrorFunction.hpp"
#include "serial/include/Network.hpp"
#include "nnhep.hpp"

int main() {
double eta{0.975};
Expand Down
4 changes: 1 addition & 3 deletions src/training_and_validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <string>
#include <sstream>

#include "serial/include/Activators.hpp"
#include "serial/include/ErrorFunction.hpp"
#include "serial/include/Network.hpp"
#include "nnhep.hpp"

void train_and_validate(double eta, int hidden_layer_size) {
Network<double, double, Sigmoid, MeanSquaredError> net({30, hidden_layer_size, 1});
Expand Down
2 changes: 1 addition & 1 deletion test/serial/ActivatorsTest/Activators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cmath>
#include <limits>

#include "../../src/serial/include/Activators.hpp"
#include "nnhep.hpp"

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
Expand Down
2 changes: 1 addition & 1 deletion test/serial/ActivatorsTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(NOT doctest_POPULATED)
endif()

# Set base directory for serial code
include_directories(../../../src/serial/)
include_directories(../../../src/)

# Compile
add_executable(Activators.out ./Activators.cc)
Expand Down
2 changes: 1 addition & 1 deletion test/serial/MatrixTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(NOT doctest_POPULATED)
endif()

# Set base directory for serial code
include_directories(../../../src/serial/)
include_directories(../../../src/)

# Compile
add_executable(MatrixSum.out ./MatrixSum.cc)
Expand Down
2 changes: 1 addition & 1 deletion test/serial/MatrixTest/MatrixMultiplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ranges>
#include <vector>

#include "DataFormats/Matrix.hpp"
#include "nnhep/DataFormats/Matrix.hpp"

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
Expand Down
2 changes: 1 addition & 1 deletion test/serial/MatrixTest/MatrixSum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ranges>
#include <vector>

#include "DataFormats/Matrix.hpp"
#include "nnhep/DataFormats/Matrix.hpp"

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
Expand Down
2 changes: 1 addition & 1 deletion test/serial/MatrixTest/MatrixTransposition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ranges>
#include <vector>

#include "DataFormats/Matrix.hpp"
#include "nnhep/DataFormats/Matrix.hpp"

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
Expand Down

0 comments on commit ad2662c

Please sign in to comment.