Skip to content

Conversation

@sdatkinson
Copy link
Owner

Summary

This PR adds a configurable bottleneck parameter to WaveNet::_Layer that allows the intermediate number of channels (going into the activation) to differ from the input/output channels. This resolves issue #170.

Changes

Core Implementation

  • Added bottleneck parameter to _Layer constructor
  • Added _bottleneck member variable to store the actual bottleneck value (not doubled when gated)
  • Updated _Layer::SetMaxBufferSize() to correctly size _z and _output_head based on bottleneck
  • Updated _Layer::Process() to use _bottleneck instead of channels for internal operations
  • Fixed _output_head to have bottleneck rows instead of channels rows

LayerArray Updates

  • Added bottleneck parameter to LayerArrayParams constructor and member variable
  • Updated _LayerArray constructor to accept and pass bottleneck to layers
  • Fixed _head_rechannel to take bottleneck input channels instead of channels
  • Fixed _head_inputs to be resized to bottleneck rows

Factory Function

  • Updated factory to read bottleneck from JSON config
  • Defaults to channels if bottleneck is not specified (maintains backward compatibility)

Tests

  • Updated all existing tests to include bottleneck parameter (using named variables for legibility)
  • Added test_layer_bottleneck() - tests bottleneck < channels for non-gated layers
  • Added test_layer_bottleneck_gated() - tests bottleneck with gated activation
  • Fixed test assertions to correctly check bottleneck rows for head outputs
  • Fixed weight layouts in tests to match Conv1D and Conv1x1 weight ordering

Bug Fixes

  • Fixed CMakeLists.txt to correctly undefine NDEBUG (was using -U_NDEBUG instead of -UNDEBUG)
  • This enables assertions in tests, ensuring test failures are properly caught

Testing

All tests pass, including the new bottleneck-specific tests.

Backward Compatibility

The factory function defaults bottleneck to channels when not specified in JSON, ensuring existing models continue to work without modification.

Resolves #170

…bottleneck parameter

- Modified the constructors of _Layer and _LayerArray to accept a new bottleneck parameter, enhancing the flexibility of the layer configurations.
- Updated relevant method calls and test cases to reflect the new parameter, ensuring consistency across the codebase.
- Adjusted JSON configuration handling to support the bottleneck parameter, maintaining backward compatibility with existing configurations.
- Added a bottleneck parameter to the constructors of _Layer and _LayerArray in various test cases, enhancing the flexibility of layer configurations.
- Implemented new test cases for layers with bottleneck configurations, including both gated and non-gated scenarios.
- Updated existing tests to utilize the bottleneck parameter, ensuring comprehensive coverage and consistency across the codebase.
… initialization comments

- Commented out tests for bottleneck and gated bottleneck layers in run_tests.cpp while investigating a resize error.
- Updated weight initialization logic in test_layer.cpp to clarify the layout for Conv1D and 1x1 convolutions, ensuring consistency with the new bottleneck parameter.
- Adjusted comments for better clarity on weight patterns and dimensions in the test cases.
- Adjusted the WaveNet Layer's SetMaxBufferSize and Process methods to correctly use the bottleneck parameter for resizing internal buffers.
- Updated the handling of activation functions to ensure they operate on the correct number of channels based on the bottleneck.
- Modified test cases to reflect changes in the Layer constructor and ensure proper functionality with the bottleneck configuration.
- Enhanced comments for clarity regarding the internal channel structure and weight initialization in tests.
- Modified the headInput matrix resizing in test_layer.cpp to utilize the bottleneck parameter instead of channels, ensuring alignment with recent changes in the WaveNet layer configuration.
- This adjustment enhances the accuracy of the test cases by reflecting the updated architecture that incorporates the bottleneck parameter.
- Introduced a new test case, test_layer_bottleneck_process_realtime_safe(), to validate that the Layer::Process() method operates correctly when the bottleneck parameter differs from the number of channels.
- Ensured that the test checks for memory allocation during processing, maintaining real-time safety.
- Updated run_tests.cpp to include this new test, enhancing coverage for bottleneck scenarios in the WaveNet layer.
@sdatkinson sdatkinson merged commit 8031a06 into main Jan 16, 2026
1 check passed
@sdatkinson sdatkinson deleted the 170-bottleneck branch January 16, 2026 04:14
@sdatkinson sdatkinson changed the title [FEAUTRE] bottlenecks in WaveNet layers [FEATURE] bottlenecks in WaveNet layers Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WaveNet layer: bottleneck

2 participants