Skip to content

Commit

Permalink
Add math_approx dependency as a submodule (#345)
Browse files Browse the repository at this point in the history
* Add math_approx dependency as a submodule

* Trying to fix headless build
  • Loading branch information
jatinchowdhury18 authored Jan 14, 2024
1 parent 6f949c6 commit 536977f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 47 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/arm-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ jobs:
token: ${{ secrets.OUR_GITHUB_PAT }}
path: modules/jai

- name: Checkout math_approx
uses: actions/checkout@v2
if: github.actor == 'jatinchowdhury18'
with:
ref: main
repository: Chowdhury-DSP/math_approx
token: ${{ secrets.OUR_GITHUB_PAT }}
path: modules/math_approx

- name: Configure
shell: bash
run: cmake -Bbuild -GXcode $CONFIGURE_ADD_ONS_FLAG -D"CMAKE_OSX_ARCHITECTURES=arm64"
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ jobs:
token: ${{ secrets.OUR_GITHUB_PAT }}
path: modules/jai

- name: Checkout math_approx
uses: actions/checkout@v2
if: github.actor == 'jatinchowdhury18'
with:
ref: main
repository: Chowdhury-DSP/math_approx
token: ${{ secrets.OUR_GITHUB_PAT }}
path: modules/math_approx

- name: Configure
shell: bash
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule "modules/melatonin_perfetto"]
path = modules/melatonin_perfetto
url = https://github.com/sudara/melatonin_perfetto
[submodule "modules/math_approx"]
path = modules/math_approx
url = https://github.com/Chowdhury-DSP/math_approx
9 changes: 2 additions & 7 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_subdirectory(RTNeural)
# add other C++ libraries
add_subdirectory(sst-cpputils)
add_subdirectory(ea_variant)
add_subdirectory(math_approx)

include(cmake/WarningFlags.cmake)
include(cmake/ConfigFlags.cmake)
Expand Down Expand Up @@ -43,6 +44,7 @@ target_link_libraries(juce_plugin_modules
chowdsp::chowdsp_visualizers
RTNeural
ea_variant
math_approx
PUBLIC
config_flags
juce::juce_recommended_lto_flags
Expand Down Expand Up @@ -99,13 +101,6 @@ if(ASIOSDK_DIR)
target_compile_definitions(juce_plugin_modules PUBLIC JUCE_ASIO=1)
endif()

if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/math_approx")
message(STATUS "Configuring math_approx")
add_subdirectory(math_approx)
target_link_libraries(juce_plugin_modules PUBLIC math_approx)
target_compile_definitions(juce_plugin_modules PRIVATE BYOD_USE_MATH_APPROX=1)
endif()

if(IOS)
target_link_libraries(juce_plugin_modules PRIVATE juce::juce_product_unlocking)
target_compile_definitions(juce_plugin_modules PUBLIC JUCE_IN_APP_PURCHASES=1)
Expand Down
1 change: 1 addition & 0 deletions modules/math_approx
Submodule math_approx added at 07408e
13 changes: 7 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ endif()
# AVX/SSE files for accelerated neural nets
make_lib_simd_runtime(rnn_accelerated processors/drive/neural_utils/RNNAccelerated.cpp)
foreach(target IN ITEMS rnn_accelerated_sse_or_arm rnn_accelerated_avx)
target_link_libraries(${target} PRIVATE config_flags juce::juce_recommended_lto_flags warning_flags)
target_link_libraries(${target}
PRIVATE
math_approx
config_flags
juce::juce_recommended_lto_flags
warning_flags
)
target_include_directories(${target}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../modules/RTNeural
Expand All @@ -183,11 +189,6 @@ foreach(target IN ITEMS rnn_accelerated_sse_or_arm rnn_accelerated_avx)
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
if(TARGET math_approx)
message(STATUS "Using math_approx for ${target}")
target_compile_definitions(${target} PRIVATE RTNEURAL_USE_MATH_APPROX=1)
target_link_libraries(${target} PRIVATE math_approx)
endif()
endforeach()
target_compile_definitions(rnn_accelerated_sse_or_arm PRIVATE RTNEURAL_DEFAULT_ALIGNMENT=16 RTNEURAL_NAMESPACE=RTNeural_sse_arm)
target_compile_definitions(rnn_accelerated_avx PRIVATE RTNEURAL_DEFAULT_ALIGNMENT=32 RTNEURAL_NAMESPACE=RTNeural_avx)
Expand Down
4 changes: 1 addition & 3 deletions src/headless/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ target_include_directories(BYOD_headless
../../modules/JUCE/modules
../../modules/chowdsp_wdf/include
../../modules/ea_variant
../../modules/math_approx/include
${juce_includes}
)
if(TARGET math_approx)
target_include_directories(BYOD_headless PRIVATE ../../modules/math_approx/include)
endif()

target_link_libraries(BYOD_headless PUBLIC
BinaryData
Expand Down
2 changes: 0 additions & 2 deletions src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE
#include "jai/SharedJaiContext.h"
#endif

#if BYOD_USE_MATH_APPROX
#include <math_approx/math_approx.hpp>
#endif

// global definitions
using Parameters = std::vector<std::unique_ptr<juce::RangedAudioParameter>>;
Expand Down
4 changes: 0 additions & 4 deletions src/processors/drive/diode_circuits/OmegaProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <pch.h>

#if BYOD_USE_MATH_APPROX
struct OmegaProvider
{
template <typename T>
Expand All @@ -11,6 +10,3 @@ struct OmegaProvider
return math_approx::wright_omega<3, 3> (x);
}
};
#else
using OmegaProvider = chowdsp::Omega::Omega;
#endif
8 changes: 1 addition & 7 deletions src/processors/drive/neural_utils/RNNAccelerated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
#endif

#include <RTNeural/RTNeural.h>

#if RTNEURAL_USE_MATH_APPROX
#include <math_approx/math_approx.hpp>

struct ApproxMathsProvider
struct RNNMathsProvider
{
template <typename T>
static T tanh (T x)
Expand All @@ -29,10 +27,6 @@ struct ApproxMathsProvider
return math_approx::sigmoid<9> (x);
}
};
using RNNMathsProvider = ApproxMathsProvider;
#else
using RNNMathsProvider = RTNEURAL_NAMESPACE::DefaultMathsProvider;
#endif

#include "model_loaders.h"

Expand Down

0 comments on commit 536977f

Please sign in to comment.