diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33ceb18..2e8bdac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,6 +35,15 @@ jobs: - os: ubuntu-latest name: "STL" backend: "-DRTNEURAL_STL=ON" + - os: ubuntu-latest + name: "Eigen / C++23" + backend: "-DRTNEURAL_EIGEN=ON -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13" + # - os: ubuntu-latest + # name: "XSIMD / C++23" + # backend: "-DRTNEURAL_XSIMD=ON -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13" + - os: ubuntu-latest + name: "STL / C++23" + backend: "-DRTNEURAL_STL=ON -DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13" - os: windows-latest name: "Eigen" backend: "-DRTNEURAL_EIGEN=ON" @@ -67,6 +76,13 @@ jobs: backend: "-DRTNEURAL_STL=ON" steps: + - name: Install Linux Deps + if: runner.os == 'Linux' + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt update + sudo apt install gcc-13 g++-13 -y + - name: Get latest CMake uses: lukka/get-cmake@latest @@ -87,4 +103,4 @@ jobs: - name: Test shell: bash - run: ctest -C Release --test-dir build --parallel --output-on-failure + run: ctest -V -C Release --test-dir build --parallel --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index f8d74b1..d0a0c4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.11) project(RTNeural VERSION 1.0.0) include(cmake/CXXStandard.cmake) include(cmake/Sanitizers.cmake) diff --git a/cmake/CXXStandard.cmake b/cmake/CXXStandard.cmake index 730c043..a83d598 100644 --- a/cmake/CXXStandard.cmake +++ b/cmake/CXXStandard.cmake @@ -2,6 +2,7 @@ if("${CMAKE_CXX_STANDARD}" STREQUAL "") message(STATUS "A C++ Standard has not been set for this project! RTNeural is selecting C++14...") set(CMAKE_CXX_STANDARD 14) else() + message(STATUS "Compiling RTNeural with C++ version ${CMAKE_CXX_STANDARD}") if(${CMAKE_CXX_STANDARD} LESS 14) message(FATAL_ERROR "RTNeural requires C++ 14 or later") endif() diff --git a/tests/functional/torch_conv1d_test.cpp b/tests/functional/torch_conv1d_test.cpp index 10be824..78b7d1a 100644 --- a/tests/functional/torch_conv1d_test.cpp +++ b/tests/functional/torch_conv1d_test.cpp @@ -3,18 +3,22 @@ #include "load_csv.hpp" #include +#if __cplusplus > 202002L +#include +#endif + namespace { template -void expectNear(T const& expected, T const& actual) +void expectNear(T const& expected, T const& actual, double error_thresh) { EXPECT_THAT( static_cast(expected), - testing::DoubleNear(static_cast(actual), 1e-6)); + testing::DoubleNear(static_cast(actual), error_thresh)); } template -void testTorchConv1DModel() +void testTorchConv1DModel(double error_thresh = 1e-6) { const auto model_file = std::string { RTNEURAL_ROOT_DIR } + "models/conv1d_torch.json"; std::ifstream jsonStream(model_file, std::ifstream::binary); @@ -43,7 +47,7 @@ void testTorchConv1DModel() { for(size_t j = 0; j < outputs[n].size(); ++j) { - expectNear(outputs[n + 4][j], expected_y[n][j]); + expectNear(outputs[n + 4][j], expected_y[n][j], error_thresh); } } } @@ -58,3 +62,17 @@ TEST(TestTorchConv1D, modelOutputMatchesPythonImplementationForDoubles) { testTorchConv1DModel(); } + +#if __STDCPP_FLOAT16_T__ +TEST(TestTorchConv1D, modelOutputMatchesPythonImplementationForFloat16) +{ + testTorchConv1DModel(1.0e-3); +} +#endif + +#if __STDCPP_BFLOAT16_T__ +TEST(TestTorchConv1D, modelOutputMatchesPythonImplementationForBFloat16) +{ + testTorchConv1DModel(1.0e-2); +} +#endif diff --git a/tests/functional/torch_gru_test.cpp b/tests/functional/torch_gru_test.cpp index bef9c4c..75b8a6f 100644 --- a/tests/functional/torch_gru_test.cpp +++ b/tests/functional/torch_gru_test.cpp @@ -3,10 +3,14 @@ #include "load_csv.hpp" #include +#if __cplusplus > 202002L +#include +#endif + namespace { template -void testTorchGRUModel() +void testTorchGRUModel(double error_thresh = 1.0e-6) { using ModelType = RTNeural::ModelT, @@ -55,7 +59,7 @@ void testTorchGRUModel() const auto expected_y = load_csv::loadFile(modelOutputsFile); using namespace testing; - EXPECT_THAT(outputs, Pointwise(DoubleNear(1e-6), expected_y)); + EXPECT_THAT(outputs, Pointwise(DoubleNear(error_thresh), expected_y)); } } @@ -68,3 +72,17 @@ TEST(TestTorchGRU, modelOutputMatchesPythonImplementationForDoubles) { testTorchGRUModel(); } + +#if __STDCPP_FLOAT16_T__ +TEST(TestTorchGRU, modelOutputMatchesPythonImplementationForFloat16) +{ + testTorchGRUModel(1.0e-3); +} +#endif + +#if __STDCPP_BFLOAT16_T__ +TEST(TestTorchGRU, modelOutputMatchesPythonImplementationForBFloat16) +{ + testTorchGRUModel(1.0e-2); +} +#endif diff --git a/tests/functional/torch_lstm_test.cpp b/tests/functional/torch_lstm_test.cpp index 523e6d3..cf529cd 100644 --- a/tests/functional/torch_lstm_test.cpp +++ b/tests/functional/torch_lstm_test.cpp @@ -3,10 +3,14 @@ #include "load_csv.hpp" #include +#if __cplusplus > 202002L +#include +#endif + namespace { template -void testTorchLSTMModel() +void testTorchLSTMModel(double error_thresh = 1.0e-6) { using ModelType = RTNeural::ModelT, @@ -55,7 +59,7 @@ void testTorchLSTMModel() const auto expected_y = load_csv::loadFile(modelOutputsFile); using namespace testing; - EXPECT_THAT(outputs, Pointwise(DoubleNear(1e-6), expected_y)); + EXPECT_THAT(outputs, Pointwise(DoubleNear(error_thresh), expected_y)); } } @@ -68,3 +72,17 @@ TEST(TestTorchLSTM, modelOutputMatchesPythonImplementationForDoubles) { testTorchLSTMModel(); } + +#if __STDCPP_FLOAT16_T__ +TEST(TestTorchLSTM, modelOutputMatchesPythonImplementationForFloat16) +{ + testTorchLSTMModel(1.0e-3); +} +#endif + +#if __STDCPP_BFLOAT16_T__ +TEST(TestTorchLSTM, modelOutputMatchesPythonImplementationForBFloat16) +{ + testTorchLSTMModel(1.0e-2); +} +#endif