Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CI pipeline with clang version 19 #63

Merged
merged 7 commits into from
Nov 4, 2024
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
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
name: Unit tests Linux
name: Unit tests Clang Linux

on: [push]

jobs:
unit-tests:
name: Build and run
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1.3
with:
version: 13
platform: x64
- name: Checkout the project
uses: actions/checkout@v2
- name: CMake
run: |
cd ./build
CXX=/usr/bin/g++-13 cmake -G"Unix Makefiles" ./.. -DCMAKE_BUILD_TYPE=Release
CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18 cmake -G"Unix Makefiles" ./.. -DCMAKE_BUILD_TYPE=Release
- name: Make
run: |
cd ./build
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/unit_tests_gcc_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unit tests GCC Linux

on: [push]

jobs:
unit-tests:
name: Build and run
runs-on: ubuntu-24.04

steps:
- name: Checkout the project
uses: actions/checkout@v2
- name: CMake
run: |
cd ./build
CC=/usr/bin/gcc-14 CXX=/usr/bin/g++-14 cmake -G"Unix Makefiles" ./.. -DCMAKE_BUILD_TYPE=Release
- name: Make
run: |
cd ./build
make
- name: Execute unit tests
run: |
cd ./build
./tests/unit_tests/UnitTests --gtest_also_run_disabled_tests
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libboost_serialization-vc143-mt-sgd-x64-1_80.lib")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math")
endif()

add_subdirectory(src)
Expand All @@ -63,5 +63,5 @@ if(MSVC)
remove_target_compile_options(DatasetTests /W3)
else()
target_compile_options(StraightforwardNeuralNetwork PUBLIC -fopenmp -Wall -Wextra -pedantic -Werror -Wno-unused-parameter)
target_compile_options(Boost PRIVATE -w)
target_compile_options(Boost INTERFACE -w)
endif()
20 changes: 0 additions & 20 deletions src/data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,26 +268,6 @@ void Data::unshuffle()

int Data::isValid()
{
for (auto& input : this->sets[training].inputs)
{
for (auto& value : input)
{
if (isnan(value))
{
return 401;
}
}
}
for (auto& input : this->sets[testing].inputs)
{
for (auto& value : input)
{
if (isnan(value))
{
return 401;
}
}
}
if (!this->sets[testing].shuffledIndexes.empty()
&& this->sets[training].size != (int)this->sets[training].shuffledIndexes.size())
return 403;
Expand Down
5 changes: 1 addition & 4 deletions src/neural_network/NeuralNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ vector<float> NeuralNetwork::calculateError(const vector<float>& outputs, const
vector<float> errors(this->layers.back()->getNumberOfNeurons(), 0);
for (size_t n = 0; n < errors.size(); ++n)
{
if (isnan(desired[n]))
errors[n] = 0;
else
errors[n] = 2 * (desired[n] - outputs[n]);
errors[n] = 2 * (desired[n] - outputs[n]);
}
return errors;
}
Expand Down
2 changes: 1 addition & 1 deletion src/neural_network/layer/Layer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ float Layer<N>::getAverageOfAbsNeuronWeights() const
auto sum = 0.0f;
for (auto& n : this->neurons)
for (auto w : n.getWeights())
sum += abs(w);
sum += std::abs(w);
sum /= static_cast<float>(this->neurons.size());
return sum;
}
Expand Down
2 changes: 1 addition & 1 deletion src/neural_network/layer/MaxPooling1D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace snn::internal

[[nodiscard]] std::vector<float> computeBackOutput(std::vector<float>& inputErrors) override;
[[nodiscard]] std::vector<float> computeOutput(const std::vector<float>& inputs, bool temporalReset) override;
void computeTrain(std::vector<float> & [[maybe_unused]] inputErrors) override {}
void computeTrain([[maybe_unused]] std::vector<float> & inputErrors) override {}
void buildKernelIndexes() override;

public:
Expand Down
2 changes: 1 addition & 1 deletion src/neural_network/layer/MaxPooling2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace snn::internal

[[nodiscard]] std::vector<float> computeBackOutput(std::vector<float>& inputErrors) override;
[[nodiscard]] std::vector<float> computeOutput(const std::vector<float>& inputs, bool temporalReset) override;
void computeTrain(std::vector<float>& [[maybe_unused]] inputErrors) override {}
void computeTrain([[maybe_unused]] std::vector<float>& inputErrors) override {}
void buildKernelIndexes() override;

public:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/IdentityTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST(Identity, WorksWithSmallNumbers)

Data data(problem::regression, inputData, expectedOutputs);

StraightforwardNeuralNetwork neuralNetwork({Input(1), FullyConnected(4), FullyConnected(1, snn::activation::identity)},
StraightforwardNeuralNetwork neuralNetwork({Input(1), FullyConnected(6), FullyConnected(1, snn::activation::identity)},
StochasticGradientDescent(0.02f, 0.99f));

neuralNetwork.train(data, 0.01_mae || 2_s);
Expand Down
Loading