### Gated Activation Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code demonstrating the gated activation process within a WaveNet layer. ```cpp if (this->_gating_mode == GatingMode::GATED) { auto input_block = this->_z.leftCols(num_frames); auto output_block = this->_z.topRows(bottleneck).leftCols(num_frames); this->_gating_activation->apply(input_block, output_block); if (this->_activation_post_film) { this->_activation_post_film->Process(this->_z.topRows(bottleneck), condition, num_frames); this->_z.topRows(bottleneck).leftCols(num_frames).noalias() = this->_activation_post_film->GetOutput().leftCols(num_frames); } } ``` -------------------------------- ### 1x1 Convolution Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code for the 1x1 convolution step, reducing bottleneck channels. ```cpp _1x1.process_(this->_z.topRows(bottleneck), num_frames); if (this->_1x1_post_film) { Eigen::MatrixXf& _1x1_output = this->_1x1.GetOutput(); this->_1x1_post_film->Process_(_1x1_output, condition, num_frames); } ``` -------------------------------- ### Layer Processing Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code demonstrating the sequential processing of layers within a LayerArray. ```cpp for (size_t i = 0; i < this->_layers.size(); i++) { if (i == 0) { // First layer consumes the rechannel output buffer this->_layers[i].Process(rechannel_output, condition, num_frames); } else { // Subsequent layers consume the residual output from the previous layer Eigen::MatrixXf& prev_output = this->_layers[i - 1].GetOutputNextLayer(); this->_layers[i].Process(prev_output, condition, num_frames); } // Accumulate head output from this layer this->_head_inputs.leftCols(num_frames).noalias() += this->_layers[i].GetOutputHead().leftCols(num_frames); } ``` -------------------------------- ### Rechanneling Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code snippet for the rechanneling step in LayerArray computation. ```cpp this->_rechannel.process_(layer_inputs, num_frames); Eigen::MatrixXf& rechannel_output = _rechannel.GetOutput(); ``` -------------------------------- ### Residual and Skip Connections Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code illustrating the computation of residual and skip connections. ```cpp // Store output to next layer (residual connection) this->_output_next_layer.leftCols(num_frames).noalias() = input.leftCols(num_frames) + _1x1.GetOutput().leftCols(num_frames); // Store output to head (skip connection) if (this->_head1x1) { this->_output_head.leftCols(num_frames).noalias() = this->_head1x1->GetOutput().leftCols(num_frames); } else { this->_output_head.leftCols(num_frames).noalias() = this->_z.topRows(bottleneck).leftCols(num_frames); } ``` -------------------------------- ### Head 1x1 Convolution Example Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code for the optional head 1x1 convolution, processing the activated output for the skip connection. ```cpp if (this->_head1x1) { this->_head1x1->process_(this->_z.topRows(bottleneck).leftCols(num_frames), num_frames); if (this->_head1x1_post_film) { Eigen::MatrixXf& head1x1_output = this->_head1x1->GetOutput(); this->_head1x1_post_film->Process_(head1x1_output, condition, num_frames); } this->_output_head.leftCols(num_frames).noalias() = this->_head1x1->GetOutput().leftCols(num_frames); } ``` -------------------------------- ### Tool Definitions Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/tools/CMakeLists.txt Sets up custom targets and executables for various tools. ```cmake set(TOOLS benchmodel) add_custom_target(tools ALL DEPENDS ${TOOLS} render) add_executable(loadmodel loadmodel.cpp ${NAM_SOURCES}) add_executable(benchmodel benchmodel.cpp ${NAM_SOURCES}) add_executable(render render.cpp ${NAM_SOURCES} ${AUDIO_DSP_TOOLS_WAV_SOURCES}) target_compile_features(render PUBLIC cxx_std_20) # AudioDSPTools wav.cpp has sign-compare issues; don't fail build set_source_files_properties(${AUDIO_DSP_TOOLS_WAV_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-error") set_target_properties(render PROPERTIES CXX_VISIBILITY_PRESET hidden INTERPROCEDURAL_OPTIMIZATION TRUE PREFIX "" ) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") target_compile_definitions(render PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN) endif() if (MSVC) target_compile_options(render PRIVATE "$<$:/W4>" "$<$:/O2>" ) else() target_compile_options(render PRIVATE -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wunreachable-code -Weffc++ -Wno-unused-parameter "$<$:-Og;-ggdb;-Werror>" "$<$:-Ofast>" ) endif() add_executable(benchmodel_bufsize benchmodel_bufsize.cpp ${NAM_SOURCES}) add_executable(bench_a2_fast bench_a2_fast.cpp ${NAM_SOURCES}) target_compile_features(bench_a2_fast PUBLIC cxx_std_20) set_target_properties(bench_a2_fast PROPERTIES CXX_VISIBILITY_PRESET hidden INTERPROCEDURAL_OPTIMIZATION TRUE PREFIX "" ) if (MSVC) target_compile_options(bench_a2_fast PRIVATE "$<$:/W4>" "$<$:/O2>" ) else() target_compile_options(bench_a2_fast PRIVATE -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wunreachable-code -Wno-unused-parameter "$<$:-Og;-ggdb;-Werror>" "$<$:-Ofast>" ) endif() add_executable(run_tests run_tests.cpp test/allocation_tracking.cpp ${NAM_SOURCES}) # Compile run_tests without optimizations to ensure allocation tracking works correctly # Also ensure assertions are enabled (NDEBUG is not defined) so tests actually run set_target_properties(run_tests PROPERTIES COMPILE_OPTIONS "-O0") # Ensure assertions are enabled for run_tests by removing NDEBUG if it was set # Release/RelWithDebInfo/MinSizeRel build types automatically define NDEBUG # We use a compile option to undefine it, which works on GCC, Clang, and MSVC target_compile_options(run_tests PRIVATE $<$,$,$>:-UNDEBUG> ) # Option to enable ADDASSERT test (tests that assertions are actually enabled) option(ENABLE_ASSERT_TEST "Enable ADDASSERT test to verify assertions are enabled" OFF) if(ENABLE_ASSERT_TEST) target_compile_definitions(run_tests PRIVATE ADDASSERT) endif() source_group(NAM ${CMAKE_CURRENT_SOURCE_DIR} FILES ${NAM_SOURCES}) target_compile_features(${TOOLS} PUBLIC cxx_std_20) set_target_properties(${TOOLS} PROPERTIES CXX_VISIBILITY_PRESET hidden INTERPROCEDURAL_OPTIMIZATION TRUE PREFIX "" ) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") target_compile_definitions(${TOOLS} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN) endif() if (MSVC) target_compile_options(${TOOLS} PRIVATE "$<$:/W4>" "$<$:/O2>" ) else() target_compile_options(${TOOLS} PRIVATE -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wunreachable-code -Weffc++ -Wno-unused-parameter "$<$:-Og;-ggdb;-Werror>" "$<$:-Ofast>" ) endif() # There's an error in eigen's # /Users/steve/src/NeuralAmpModelerCore/Dependencies/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h # Don't let this break my build on debug: set_source_files_properties(../NAM/dsp.cpp PROPERTIES COMPILE_FLAGS "-Wno-error") set_source_files_properties(../NAM/conv1d.cpp PROPERTIES COMPILE_FLAGS "-Wno-error") ``` -------------------------------- ### Project Definition Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Defines the project name and version. ```cmake # Make sure this matches ./NAM/version.h! project(NAM VERSION 0.4.0) ``` -------------------------------- ### Head Scaling and Output Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md Scales the final head output from the last LayerArray and writes it to the output buffers. ```cpp Eigen::MatrixXf& final_head = this->_layer_arrays.back().GetHeadOutputs(); // Apply head scale and write to output buffers // (implementation details in wavenet.cpp) ``` -------------------------------- ### Layer Computation: Input Mixin Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code illustrating the input mixin step, handling optional pre-FiLM, input mixin convolution, and optional post-FiLM. ```cpp if (this->_input_mixin_pre_film) { this->_input_mixin_pre_film->Process(condition, condition, num_frames); this->_input_mixin.process_(this->_input_mixin_pre_film->GetOutput(), num_frames); } else { this->_input_mixin.process_(condition, num_frames); } if (this->_input_mixin_post_film) { Eigen::MatrixXf& input_mixin_output = this->_input_mixin.GetOutput(); this->_input_mixin_post_film->Process_(input_mixin_output, condition, num_frames); } ``` -------------------------------- ### Layer Computation: Input Convolution Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code demonstrating the input convolution step within a Layer, including optional pre-FiLM, dilated convolution, and optional post-FiLM. ```cpp if (this->_conv_pre_film) { this->_conv_pre_film->Process(input, condition, num_frames); this->_conv.Process(this->_conv_pre_film->GetOutput(), num_frames); } else { this->_conv.Process(input, num_frames); } if (this->_conv_post_film) { Eigen::MatrixXf& conv_output = this->_conv.GetOutput(); this->_conv_post_film->Process_(conv_output, condition, num_frames); } ``` -------------------------------- ### A2 Fast-Path WaveNet Option Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Option to enable a specialized, hand-optimized WaveNet implementation for A2 models. ```cmake # Build the specialized A2 fast-path WaveNet (A2 standard + A2 nano). When ON, # models whose config matches the A2 shape signature are routed to a hand-optimized # WaveNet implementation instead of the generic one. When OFF, all models go # through the generic path. option(NAM_ENABLE_A2_FAST "Build the A2 fast-path WaveNet" ON) if(NAM_ENABLE_A2_FAST) add_compile_definitions(NAM_ENABLE_A2_FAST) endif() ``` -------------------------------- ### C++ Standard Configuration Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Sets the C++ standard to C++20 and related requirements. ```cmake set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED OFF) set(CMAKE_CXX_EXTENSIONS OFF) ``` -------------------------------- ### libc++ Option for Linux Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Option to enable libc++ on Linux. ```cmake option(NAM_USE_LIBCXX_LINUX "Use libc++ on Linux (Clang + libc++-dev packages; tests SlimmableWavenet _LIBCPP_VERSION path)" OFF) ``` -------------------------------- ### Dependencies Path Configuration Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Sets the path for project dependencies and includes them. ```cmake set(NAM_DEPS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Dependencies") include_directories(SYSTEM "${NAM_DEPS_PATH}/eigen") ``` -------------------------------- ### Condition Processing Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md Processes the input through a condition DSP to generate the conditioning signal, or uses the input directly if no DSP is provided. ```cpp void WaveNet::_process_condition(const int num_frames) { if (this->_condition_dsp != nullptr) { // Process input through condition DSP this->_condition_dsp->process(/* input */, /* output */, num_frames); // Copy output to condition buffer } else { // Use input directly as condition this->_condition_output = this->_condition_input; } } ``` -------------------------------- ### Module Path Configuration Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Sets the path for CMake modules. ```cmake set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") ``` -------------------------------- ### Add Subdirectory for Tools Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Includes the 'tools' subdirectory into the build. ```cmake add_subdirectory(tools) ``` -------------------------------- ### Layer Computation: Sum and Pre-Activation FiLM Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md C++ code showing the summation of convolution and input mixin outputs, followed by optional pre-activation FiLM modulation. ```cpp this->_z.leftCols(num_frames).noalias() = _conv.GetOutput().leftCols(num_frames) + _input_mixin.GetOutput().leftCols(num_frames); if (this->_activation_pre_film) { this->_activation_pre_film->Process_(this->_z, condition, num_frames); } ``` -------------------------------- ### CMake Minimum Required Version Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Specifies the minimum version of CMake required to build the project. ```cmake cmake_minimum_required(VERSION 3.10) ``` -------------------------------- ### Head Rechanneling Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md Projects the accumulated head outputs to the final output dimension for the layer array. ```cpp _head_rechannel.process_(this->_head_inputs, num_frames); ``` -------------------------------- ### Source File Globbing Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/tools/CMakeLists.txt Defines source files for the NAM library using globbing. ```cmake file(GLOB NAM_SOURCES_TOP "${CMAKE_CURRENT_SOURCE_DIR}/../NAM/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/../NAM/*.c") file(GLOB NAM_SOURCES_SUB "${CMAKE_CURRENT_SOURCE_DIR}/../NAM/*/*.cpp") set(NAM_SOURCES ${NAM_SOURCES_TOP} ${NAM_SOURCES_SUB}) ``` -------------------------------- ### Platform-Specific C++ Flags (Linux/Windows) Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Configures C++ flags and libraries based on the operating system. ```cmake if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") include_directories(SYSTEM /usr/local/include) elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") if (NAM_USE_LIBCXX_LINUX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # Clang links libc++/libc++abi; do not pull in libstdc++fs (libstdc++). else() link_libraries(stdc++fs) endif() elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") add_compile_definitions(NOMINMAX WIN32_LEAN_AND_MEAN) else() message(FATAL_ERROR "Unrecognized Platform!") endif() ``` -------------------------------- ### Platform-Specific C++ Flags (macOS) Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/CMakeLists.txt Adds libc++ to CMAKE_CXX_FLAGS on macOS. ```cmake if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() ``` -------------------------------- ### LayerArray Processing Source: https://github.com/sdatkinson/neuralampmodelercore/blob/main/docs/wavenet_walkthrough.md Processes the output of the previous LayerArray, accumulating head inputs. The first LayerArray processes the input with zeroed head inputs, while subsequent LayerArrays use the previous array's output and head inputs. ```cpp // First layer array this->_layer_arrays[0].Process(input, condition, num_frames); // Subsequent layer arrays for (size_t i = 1; i < this->_layer_arrays.size(); i++) { Eigen::MatrixXf& prev_output = this->_layer_arrays[i-1].GetLayerOutputs(); Eigen::MatrixXf& prev_head = this->_layer_arrays[i-1].GetHeadOutputs(); this->_layer_arrays[i].Process(prev_output, condition, prev_head, num_frames); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.