From 91efeb06276ecb76f7afe73c4595e4c666ddde31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Felipe=20Santos?= Date: Mon, 9 Mar 2026 11:07:12 -0700 Subject: [PATCH 1/5] Slimmable interface and SlimmableContainer added. --- NAM/container.cpp | 127 ++++++++++ NAM/container.h | 61 +++++ NAM/dsp.h | 7 + example_models/slimmable_container.nam | 1 + tools/run_tests.cpp | 13 + tools/test/test_container.cpp | 313 +++++++++++++++++++++++++ 6 files changed, 522 insertions(+) create mode 100644 NAM/container.cpp create mode 100644 NAM/container.h create mode 100644 example_models/slimmable_container.nam create mode 100644 tools/test/test_container.cpp diff --git a/NAM/container.cpp b/NAM/container.cpp new file mode 100644 index 00000000..b5f4e128 --- /dev/null +++ b/NAM/container.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include + +#include "container.h" +#include "get_dsp.h" +#include "model_config.h" + +namespace nam +{ +namespace container +{ + +// ============================================================================= +// ContainerModel +// ============================================================================= + +ContainerModel::ContainerModel(std::vector submodels, const double expected_sample_rate) +: DSP(1, 1, expected_sample_rate) +, _submodels(std::move(submodels)) +{ + if (_submodels.empty()) + throw std::runtime_error("ContainerModel: no submodels provided"); + + // Validate ordering and that final max_value covers 1.0 + for (size_t i = 1; i < _submodels.size(); ++i) + { + if (_submodels[i].max_value <= _submodels[i - 1].max_value) + throw std::runtime_error("ContainerModel: submodels must be sorted by ascending max_value"); + } + if (_submodels.back().max_value < 1.0) + throw std::runtime_error("ContainerModel: last submodel max_value must be >= 1.0"); + + // Validate all submodels have the same expected sample rate + for (const auto& sm : _submodels) + { + double sr = sm.model->GetExpectedSampleRate(); + if (sr != expected_sample_rate && sr != NAM_UNKNOWN_EXPECTED_SAMPLE_RATE + && expected_sample_rate != NAM_UNKNOWN_EXPECTED_SAMPLE_RATE) + { + std::stringstream ss; + ss << "ContainerModel: submodel sample rate mismatch (expected " << expected_sample_rate << ", got " << sr << ")"; + throw std::runtime_error(ss.str()); + } + } + + // Default to full size (last submodel) + _active_index = _submodels.size() - 1; +} + +void ContainerModel::process(NAM_SAMPLE** input, NAM_SAMPLE** output, const int num_frames) +{ + _active_model().process(input, output, num_frames); +} + +void ContainerModel::prewarm() +{ + for (auto& sm : _submodels) + sm.model->prewarm(); +} + +void ContainerModel::Reset(const double sampleRate, const int maxBufferSize) +{ + DSP::Reset(sampleRate, maxBufferSize); + for (auto& sm : _submodels) + sm.model->Reset(sampleRate, maxBufferSize); +} + +void ContainerModel::SetSlimmableSize(const double val) +{ + _active_index = _submodels.size() - 1; + for (size_t i = 0; i < _submodels.size(); ++i) + { + if (val <= _submodels[i].max_value) + { + _active_index = i; + break; + } + } + + const double sr = mHaveExternalSampleRate ? mExternalSampleRate : mExpectedSampleRate; + _active_model().ResetAndPrewarm(sr, GetMaxBufferSize()); +} + +// ============================================================================= +// Config / factory +// ============================================================================= + +std::unique_ptr ContainerConfig::create(std::vector weights, double sampleRate) +{ + (void)weights; // Container has no top-level weights + + auto submodels_json = raw_config["submodels"]; + if (!submodels_json.is_array() || submodels_json.empty()) + throw std::runtime_error("SlimmableContainer: 'submodels' must be a non-empty array"); + + std::vector submodels; + submodels.reserve(submodels_json.size()); + + for (const auto& entry : submodels_json) + { + double max_val = entry.at("max_value").get(); + const auto& model_json = entry.at("model"); + + // Each submodel is a full NAM model spec (has architecture, config, weights, etc.) + auto dsp = get_dsp(model_json); + + submodels.push_back({max_val, std::move(dsp)}); + } + + return std::make_unique(std::move(submodels), sampleRate); +} + +std::unique_ptr create_config(const nlohmann::json& config, double sampleRate) +{ + auto c = std::make_unique(); + c->raw_config = config; + c->sample_rate = sampleRate; + return c; +} + +// Auto-register +static ConfigParserHelper _register_SlimmableContainer("SlimmableContainer", create_config); + +} // namespace container +} // namespace nam diff --git a/NAM/container.h b/NAM/container.h new file mode 100644 index 00000000..0a4b1a87 --- /dev/null +++ b/NAM/container.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include +#include + +#include "dsp.h" +#include "model_config.h" + +namespace nam +{ +namespace container +{ + +struct Submodel +{ + double max_value; + std::unique_ptr model; +}; + +/// \brief A container model that holds multiple submodels at different sizes +/// +/// SetSlimmableSize selects the active submodel based on the max_value thresholds. +/// Each submodel covers values up to (and including) its max_value. +class ContainerModel : public DSP +{ +public: + /// \brief Constructor + /// \param submodels Vector of submodels sorted by max_value ascending + /// \param expected_sample_rate Expected sample rate in Hz + ContainerModel(std::vector submodels, const double expected_sample_rate); + + void process(NAM_SAMPLE** input, NAM_SAMPLE** output, const int num_frames) override; + void prewarm() override; + void Reset(const double sampleRate, const int maxBufferSize) override; + void SetSlimmableSize(const double val) override; + +protected: + int PrewarmSamples() override { return 0; } + +private: + std::vector _submodels; + size_t _active_index = 0; + + DSP& _active_model() { return *_submodels[_active_index].model; } +}; + +// Config / registration + +struct ContainerConfig : public ModelConfig +{ + nlohmann::json raw_config; + double sample_rate; + + std::unique_ptr create(std::vector weights, double sampleRate) override; +}; + +std::unique_ptr create_config(const nlohmann::json& config, double sampleRate); + +} // namespace container +} // namespace nam diff --git a/NAM/dsp.h b/NAM/dsp.h index 15bc9b81..f41abc0c 100644 --- a/NAM/dsp.h +++ b/NAM/dsp.h @@ -155,6 +155,13 @@ class DSP /// \param outputLevel Output level in dBu void SetOutputLevel(const double outputLevel); + /// \brief Set the slimmable size of the model + /// + /// This is a hint that allows models to reduce their computational cost. + /// The interpretation is model-specific. The default implementation is a no-op. + /// \param val Value between 0.0 (minimum size) and 1.0 (maximum size) + virtual void SetSlimmableSize(const double val) { (void)val; }; + protected: friend class wavenet::WaveNet; // Allow WaveNet to access protected members. Used in condition DSP. diff --git a/example_models/slimmable_container.nam b/example_models/slimmable_container.nam new file mode 100644 index 00000000..5099a9c2 --- /dev/null +++ b/example_models/slimmable_container.nam @@ -0,0 +1 @@ +{"version": "0.6.1", "architecture": "SlimmableContainer", "config": {"submodels": [{"max_value": 0.33, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 44, "second": 41}, "loudness": -37.8406867980957, "gain": 0.13508800804658277, "name": "Test LSTM", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": null}}, "architecture": "LSTM", "config": {"input_size": 1, "hidden_size": 3, "num_layers": 1}, "weights": [-0.21677088737487793, -0.6683622002601624, -0.2560940980911255, -0.3588429093360901, 0.17952610552310944, 0.19445613026618958, -0.01662646047770977, 0.5353694558143616, -0.2536540627479553, -0.5132213234901428, -0.020476307719945908, 0.08592455089092255, -0.6891753673553467, 0.3627359867095947, 0.008421811275184155, 0.3113192617893219, 0.14251480996608734, 0.07989779114723206, -0.18211324512958527, 0.7118963003158569, 0.41084015369415283, -0.6571938395500183, -0.13214066624641418, -0.2698603868484497, 0.49387243390083313, -0.3491725027561188, 0.6353667974472046, -0.5005152225494385, 0.2052856683731079, -0.4301638901233673, -0.15770092606544495, -0.7181791067123413, 0.056290093809366226, -0.49049463868141174, 0.6623441576957703, 0.09029324352741241, 0.34005245566368103, 0.16416560113430023, 0.15520110726356506, -0.4155678153038025, -0.36928507685661316, 0.3211132884025574, -0.6769840121269226, -0.1575538069009781, 0.05268515646457672, -0.4191459119319916, 0.599330484867096, 0.21518059074878693, -4.246325492858887, -3.315647840499878, -4.328850746154785, 4.496089458465576, 5.015639305114746, 3.6492037773132324, 0.14431169629096985, -0.6633821725845337, 0.11673200130462646, -0.1418764889240265, -0.4897872805595398, -0.8689419031143188, -0.06714004278182983, -0.4450395107269287, -0.02142983116209507, -0.15136894583702087, -2.775207996368408, -0.08681213855743408, 0.05702732503414154, 0.670292317867279, 0.31442636251449585, 0.30793967843055725], "sample_rate": 48000}}, {"max_value": 0.66, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 32, "second": 27}, "loudness": -20.020729064941406, "gain": 0.19575619747898518, "name": "Test Model", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.13345033695550146}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 3, "kernel_size": 3, "dilations": [1, 2], "activation": "Tanh", "gated": false, "head_bias": false}, {"input_size": 3, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [8], "activation": "Tanh", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.6180188059806824, 1.0314024686813354, -1.0111560821533203, -0.38462021946907043, 0.35968291759490967, 0.5255971550941467, 0.19149275124073029, -0.18075695633888245, -0.33711034059524536, -0.21037575602531433, 0.2007753700017929, 0.21644853055477142, -1.3216396570205688, -0.35082393884658813, 0.43541353940963745, 0.9693092107772827, 0.2394428700208664, -0.41078877449035645, -1.193748116493225, -0.14876757562160492, 0.8413559198379517, 0.24491633474826813, 0.8857091665267944, 0.5647665858268738, 0.08301573246717453, -0.801490843296051, 0.168976828455925, -0.5413634181022644, 0.484220415353775, 0.021656272932887077, -0.15155009925365448, 0.07081033289432526, 0.00019397131109144539, -0.7408013939857483, -1.3308452367782593, -1.0403972864151, 0.016809873282909393, 0.6778652667999268, 0.28265541791915894, -0.28287461400032043, 1.0525944232940674, -0.6385797262191772, -0.2195468544960022, -0.3150196671485901, -0.8814508318901062, -0.2746180295944214, 0.15367186069488525, 0.22431065142154694, -0.056788790971040726, -0.38902369141578674, 0.5406259894371033, 0.3566059470176697, 0.14383991062641144, -0.25409433245658875, 0.16139137744903564, -0.05857989564538002, -0.18448838591575623, -0.253485769033432, -0.42405444383621216, -0.030114537104964256, 0.47283637523651123, 0.14930365979671478, -0.4410354793071747, -0.21976807713508606, -0.12736600637435913, -0.5674286484718323, -0.347588449716568, -0.3687525689601898, 0.4130803942680359, 0.8551775217056274, -0.05746064335107803, -0.38243237137794495, 0.20036561787128448, 0.25542038679122925, -0.0819990262389183, 0.19469600915908813, 0.10215214639902115, -0.26087674498558044, -0.1773151010274887, -0.09658292680978775, -0.7381710410118103, 0.7003506422042847, 0.7253592014312744, -0.07488955557346344, -0.23439547419548035, -0.5138604044914246, -0.7976311445236206, -0.8090851902961731, -0.37562188506126404, -1.163352131843567, 0.30907657742500305, 0.0564480796456337, 0.1190297082066536, 0.2310808300971985, -0.45360898971557617, -0.11524498462677002, 0.2552330493927002, 0.2913571298122406, -0.23171702027320862, -0.35578709840774536, 0.40732908248901367, 0.7458747029304504, 0.27514976263046265, -0.7503036856651306, -0.6707972884178162, -0.4248569905757904, -0.1671624332666397, -0.14162226021289825, 0.37550851702690125, -0.038120146840810776, 0.16232982277870178, -0.05173371359705925, -0.2842361629009247, 0.38820165395736694, 0.521754801273346, -0.3581869900226593, 0.21531476080417633, 0.11342520266771317, 0.01764630153775215, 0.07780527323484421, 0.9356631636619568, 0.04235581308603287, -0.3450177311897278, 0.3345951437950134, -0.678291380405426, -0.4191069006919861, -0.1770099401473999, -5.386871337890625, -5.130850791931152, -0.4049331247806549, 0.019999999552965164], "sample_rate": 48000}}, {"max_value": 1.0, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2026, "month": 1, "day": 18, "hour": 19, "minute": 28, "second": 2}, "loudness": -25.50621795654297, "gain": 0.8174147104354939, "name": "Atrisan 100 HT Pedal Jump Chan Voice 4 Blend 50 - Nuvo N22", "modeled_by": "tone3000", "gear_type": "amp", "gear_make": "tz-make", "gear_model": "tz-model", "tone_type": "overdrive", "input_level_dbu": 8.25, "output_level_dbu": 4, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [335], "safety_factor": 1, "recommended": 334, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.05744442289189271}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 4, "kernel_size": 3, "dilations": [1, 2, 4, 8, 16, 32, 64], "activation": "ReLU", "gated": false, "head_bias": false}, {"input_size": 4, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512], "activation": "ReLU", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.43676555156707764, 0.18804845213890076, -1.191544771194458, -1.2514153718948364, 0.1522054672241211, 0.2674163281917572, 0.11941885948181152, -0.016747985035181046, -0.24142038822174072, -0.08158593624830246, 0.1658506542444229, 0.12450455874204636, -0.1257639080286026, 0.05097454413771629, 0.06655367463827133, 0.15613363683223724, 0.3628908693790436, 0.16920273005962372, -0.4865663945674896, -0.33004868030548096, 0.1686093509197235, 0.4942941963672638, 0.14733701944351196, 0.1264810413122177, -0.3330173194408417, 0.2558712959289551, 0.1980869621038437, -0.5377613306045532, -0.44927188754081726, -0.10965251177549362, -0.2049286812543869, 0.5187842845916748, -0.11666373908519745, -0.010038944892585278, -0.4929092228412628, -0.3522462546825409, -0.30443158745765686, -0.05553298071026802, 0.032637786120176315, -0.01095358282327652, -0.2228831946849823, -0.07661055028438568, 0.18166741728782654, -0.02288321778178215, -0.2550153434276581, -0.27006709575653076, -0.05640152841806412, 0.2399696558713913, 0.01374511606991291, -0.2519863247871399, 0.25369852781295776, 0.43098628520965576, 0.24656431376934052, 0.05089268833398819, 0.2244647890329361, -0.3239988088607788, 0.026821687817573547, -0.5183702707290649, -0.549621045589447, -0.6563447117805481, -0.17373943328857422, -0.32807308435440063, 0.2662317454814911, -0.5284045934677124, 0.4098321795463562, -0.1177985891699791, -0.3497377634048462, 0.06472523510456085, 0.2881721258163452, 0.4962410628795624, -0.4693456292152405, 0.22105255722999573, 0.5390405058860779, 0.6857721209526062, 0.13449627161026, -0.22106148302555084, -0.015273668803274632, -0.15233269333839417, 0.0054369233548641205, -0.2990502715110779, -0.6390000581741333, 0.09520208835601807, 0.5206401348114014, -0.30539414286613464, 0.005384453106671572, -0.11123053729534149, -0.3819287419319153, -0.2212216705083847, 0.4531766176223755, -0.6183855533599854, -0.07028502225875854, 0.5584202408790588, 0.03141379728913307, 0.03053859807550907, 0.08987420797348022, 0.10635538399219513, -0.004241787828505039, -0.2514967918395996, 0.4621999263763428, -0.24512320756912231, 0.020135050639510155, 0.42594560980796814, -0.3939764201641083, -0.4036279320716858, -0.6264017820358276, 0.12763042747974396, -0.11675230413675308, -0.3192313015460968, -0.0003565576334949583, -0.06628905236721039, -0.3489648103713989, -0.18046769499778748, -0.042343053966760635, 0.20209242403507233, -0.044064972549676895, 0.010927309282124043, -0.4592772126197815, -0.2547818720340729, 0.4999264180660248, -0.04825885593891144, 0.2511541247367859, -0.05963046848773956, -0.4923741817474365, -0.19782790541648865, 0.18921701610088348, -0.143302783370018, -0.417974591255188, 0.4820250868797302, -0.01435916032642126, -0.09722636640071869, 0.04334542900323868, 0.20531202852725983, -0.6767648458480835, -0.03919640928506851, 0.41943681240081787, -0.705767810344696, 1.0928969383239746, 0.008152804337441921, 0.30072590708732605, 0.700724720954895, 1.4694486856460571, -0.36657166481018066, 0.29822444915771484, 0.08182942867279053, -1.1029194593429565, 0.39373770356178284, 0.572385847568512, -0.10765771567821503, 0.6150015592575073, 0.7301293611526489, -0.8640158772468567, -0.6661192178726196, -0.17441526055335999, 0.23340773582458496, 0.2347957193851471, -0.5018205642700195, 0.04749491065740585, -0.25646737217903137, -0.12705065310001373, -0.2656175196170807, -0.14754967391490936, -0.16251829266548157, -0.26762738823890686, -0.2506292164325714, -0.023960385471582413, 0.08543525636196136, -0.051170505583286285, 0.24774709343910217, -0.29134371876716614, 0.25539499521255493, 0.19203688204288483, -0.09644774347543716, 0.045086562633514404, 0.2614458203315735, -0.14013680815696716, 0.5095819234848022, 0.1808817982673645, 0.13184405863285065, 0.2857828140258789, -0.2877650856971741, 0.025841550901532173, -0.10298394411802292, 0.4531080424785614, 0.19967995584011078, -0.0035516824573278427, 0.6057309508323669, -0.01614478975534439, -0.024831678718328476, -0.23062309622764587, 0.0057058511301875114, -0.22100116312503815, 0.6274505257606506, -0.09544087946414948, -0.47833094000816345, -0.07983476668596268, -0.32524535059928894, -0.9022202491760254, 0.17296163737773895, 0.1715262085199356, 0.44342607259750366, 0.0672280341386795, 0.3143714964389801, -0.16193732619285583, -0.5337017774581909, -0.23426392674446106, 0.31633561849594116, 0.16039276123046875, 0.3396058678627014, 0.1790986955165863, 0.22826147079467773, 0.565819501876831, -0.18677009642124176, 0.11501625180244446, -0.9280168414115906, -0.5102543234825134, 0.4280734062194824, -0.4131118953227997, -0.3216524124145508, -0.9526995420455933, -0.8283767700195312, -0.02265196479856968, 0.3181364834308624, -0.13400879502296448, -0.3635147213935852, -0.07217840850353241, 0.5390769839286804, 0.022873638197779655, 0.15108828246593475, 0.06688182055950165, -0.06298623979091644, -0.04183664545416832, 0.26526492834091187, -0.20283886790275574, 0.8089739084243774, 0.39357757568359375, -0.4892053008079529, -0.4210922122001648, 0.0030071621295064688, 0.1889152228832245, -0.3113728165626526, 0.04760019853711128, 0.5401822924613953, -0.31828656792640686, -0.022103704512119293, -0.7838840484619141, 0.23758691549301147, 0.6584234237670898, -0.14207355678081512, 0.3508256673812866, 0.24494409561157227, 0.37631094455718994, -0.036634355783462524, 1.0158957242965698, -0.4377710223197937, -0.2699510157108307, 0.011075957678258419, -0.9512584209442139, 1.0744872093200684, 0.07266976684331894, -0.5702192783355713, -0.22477132081985474, 0.10158557444810867, 0.5408655405044556, -0.05424047261476517, -0.22979958355426788, 0.12589116394519806, -0.3061460554599762, -0.007357880473136902, 0.160592719912529, -0.8183864951133728, -0.1873759627342224, 0.4029034972190857, 0.20340028405189514, -0.19033348560333252, -0.6387582421302795, 0.3744193911552429, 0.4734930992126465, -0.7402716279029846, 0.16290104389190674, 0.231669083237648, 0.22414864599704742, 0.003755988087505102, -0.0671466663479805, 0.1964668184518814, 0.014198299497365952, 0.163277730345726, -0.26071494817733765, 0.35350218415260315, -0.686671793460846, 0.459243506193161, -0.09164588153362274, 0.7604275345802307, 0.4730943739414215, 0.35176384449005127, 0.44463688135147095, 0.035675011575222015, 0.2871439754962921, -0.21191704273223877, 0.8446514010429382, -0.881138026714325, -0.5140098929405212, -0.2590724527835846, -0.6394899487495422, 1.0582557916641235, 0.19049172103405, -0.007477824576199055, -0.0690576359629631, 0.10438528656959534, 0.46519139409065247, 0.2671721279621124, -0.8850185871124268, -0.07695616781711578, 0.06778068840503693, 0.09831968694925308, 0.425837904214859, 0.21560505032539368, -0.0973641574382782, 0.11831096559762955, 0.2720680832862854, -0.8112271428108215, 0.0679216980934143, 0.0034201480448246002, -1.1940691471099854, 0.015147575177252293, 0.2989473044872284, 0.4385072588920593, 0.22488915920257568, -0.07610563188791275, 0.24487024545669556, 0.16010652482509613, -0.1590120494365692, -0.8069810271263123, 0.3454744517803192, 0.10192205011844635, -0.5487010478973389, 0.08557324856519699, -0.0033477218821644783, -0.40646129846572876, -0.3718165159225464, 0.07761954516172409, -0.1472809761762619, -0.39236438274383545, -0.04602040350437164, -0.2916988134384155, -0.35268932580947876, 0.44220033288002014, 1.061747431755066, 0.01184292882680893, 0.029237236827611923, -0.3696916997432709, -0.3326391875743866, 0.3186306059360504, -0.0686657726764679, -0.12802480161190033, 0.059870608150959015, 0.4420037567615509, -0.11589302867650986, 0.10948559641838074, 0.3228295147418976, 0.30819857120513916, -0.5482281446456909, -1.5860124826431274, -1.1525928974151611, 0.501322865486145, 0.24488481879234314, 0.3214830756187439, 0.46026182174682617, -1.3560254573822021, -0.6456385850906372, -0.7880288362503052, 0.8956019878387451, 0.41244542598724365, -0.6440726518630981, -0.7221627235412598, -0.25085917115211487, -0.7078524231910706, 0.4188958704471588, 0.45524659752845764, 0.3029322028160095, -0.22305667400360107, 0.44652125239372253, 0.24373604357242584, 0.3368196487426758, 0.1511261910200119, 0.2610892951488495, -0.012466066516935825, 0.519991397857666, 0.3664250671863556, 0.04987747222185135, -0.04385135695338249, -0.2866438329219818, -0.016423135995864868, -0.6226651668548584, -0.07403579354286194, -0.25110307335853577, 0.13762260973453522, 0.3649454116821289, -0.04414776712656021, -0.02799362502992153, 0.39993947744369507, -0.059658318758010864, -0.5658756494522095, -0.38595327734947205, 0.12831152975559235, -0.6940039396286011, -0.21010565757751465, 0.0833023339509964, 0.2953319549560547, -0.2192569226026535, -9.963240881916136e-05, -0.4918636083602905, -0.35004717111587524, -0.11263000965118408, 0.5789287090301514, 0.333292156457901, 0.03616069629788399, -0.723102331161499, 0.07424107939004898, 0.27536284923553467, -0.3164575397968292, 0.4204881191253662, -0.10002204775810242, 0.045674219727516174, 0.4877814054489136, -0.13877654075622559, -0.9487224817276001, -0.5420687794685364, 0.15843534469604492, -0.8356834053993225, -0.3401522934436798, -0.021845858544111252, 0.24137890338897705, 0.6131256222724915, -0.5279566645622253, 0.4040375053882599, -0.287713885307312, -0.32596370577812195, -0.289026141166687, -0.8558264970779419, -0.8393163681030273, -0.6748902797698975, -1.5344449281692505, -0.48501765727996826, 0.7561529278755188, -0.5639386773109436, 0.2747798264026642, 0.31883418560028076, 0.46465715765953064, 0.8148818016052246, -1.0762479305267334, 0.5226246118545532, 0.8592436909675598, 0.05685063451528549, -1.098716378211975, 1.0224401950836182, 1.6439732313156128, 0.15941590070724487, 0.33981525897979736, -0.736503005027771, -0.1396108865737915, -0.3593847453594208, 0.18113897740840912, 0.3901767134666443, 0.24246807396411896, -0.3559393584728241, 0.3014945983886719, 0.5807337760925293, 0.632666289806366, -0.3279235064983368, -0.3521895110607147, 0.21897214651107788, 0.2008153200149536, 0.18349437415599823, 0.2843616306781769, -0.07296476513147354, 0.0050212121568620205, 0.1398988664150238, -0.04363537207245827, -0.10488884150981903, 0.018994251266121864, -0.8944122195243835, -0.1002153530716896, -0.12303996831178665, -0.6947574019432068, -0.20797944068908691, -0.25055378675460815, 0.8080053925514221, -0.1779334545135498, -0.21596449613571167, -0.5812117457389832, 0.07938572019338608, 0.31331679224967957, 1.3328310251235962, -0.1157936379313469, -0.20552347600460052, 0.2777186930179596, -0.4894363582134247, 0.1485048085451126, 0.2016707956790924, 0.12642067670822144, -0.6121338605880737, 0.07307889312505722, 0.5374605655670166, 0.6080096960067749, -0.7628602981567383, -0.4795125722885132, 0.14357036352157593, 0.03981512784957886, -0.47786933183670044, 0.548004150390625, -0.4770188629627228, -0.007587160915136337, 0.4921312630176544, -1.8222495317459106, 0.8633298873901367, -0.24518749117851257, -1.1610788106918335, -0.7625094652175903, 0.562911331653595, 0.8363901376724243, -0.5850722789764404, 0.18943746387958527, -0.19145213067531586, 0.5438283085823059, 0.27744850516319275, -0.8637493848800659, 1.191653847694397, -0.6768492460250854, -0.30685824155807495, -1.0220935344696045, 1.1770503520965576, 1.064857840538025, -0.09791866689920425, -0.49691858887672424, -0.18965063989162445, 0.18372981250286102, -0.180926114320755, -0.11052561551332474, -0.14311599731445312, -0.0899554044008255, -0.23982501029968262, -0.14997008442878723, -0.18971434235572815, -0.1178363487124443, 0.14658032357692719, 0.2887987494468689, -0.311062216758728, 0.013476553373038769, -0.019368484616279602, 0.17613445222377777, -0.3448125123977661, -0.1364353895187378, 0.07437089085578918, -0.005232963245362043, -0.17424525320529938, 0.0005958561087027192, 0.011437807232141495, -0.3326968848705292, 0.15036839246749878, 0.27264437079429626, -0.06121019273996353, -0.11970936506986618, -0.21436360478401184, 1.2016054391860962, 0.25149083137512207, 0.540777862071991, 0.0015413237269967794, -0.47897058725357056, 0.6974573731422424, -0.5686131715774536, 0.8093838095664978, 1.7492735385894775, -0.08586230874061584, -1.1748616695404053, -0.0019973507151007652, -0.10483703017234802, 1.1019824743270874, 0.00916005577892065, -0.05810127034783363, -0.08483171463012695, -0.33433252573013306, 0.47186142206192017, -0.03784961998462677, -0.10008599609136581, -0.06760873645544052, 0.11731500178575516, 2.083373546600342, 0.36512690782546997, 0.12359095364809036, -0.17322567105293274, -0.5954174399375916, -0.664002001285553, -0.7559688687324524, 0.2585269510746002, 0.09203799068927765, -0.34636759757995605, 0.15286214649677277, 0.03661971911787987, 0.5951442122459412, 0.004546092823147774, -0.03838701173663139, -0.5216450691223145, -0.15255127847194672, 0.6591381430625916, -0.42587870359420776, -0.013055965304374695, 0.26791542768478394, -0.42988717555999756, 0.06328100711107254, 0.8119242787361145, 0.11873671412467957, -0.6298862099647522, 0.5956037044525146, -0.7082923054695129, -0.8452447652816772, 0.23914732038974762, 0.21034133434295654, -0.717399001121521, 0.2983108162879944, 0.6209869980812073, -0.140838623046875, -0.4220437705516815, -0.8811973929405212, 0.40350261330604553, 0.23589693009853363, 0.3691011071205139, 0.6700326204299927, -0.39092186093330383, -0.6132438778877258, -0.026762746274471283, 0.8621531128883362, 1.1332632303237915, -0.041316304355859756, 0.02003556117415428, 0.634650468826294, -1.5741407871246338, -0.8863347768783569, -0.8439550399780273, -1.366637110710144, 0.06646597385406494, -0.3964800238609314, -0.41438424587249756, 0.6846640706062317, -0.7748998999595642, -0.8067624568939209, -0.030613016337156296, -0.16540996730327606, 0.3083365559577942, -0.37768617272377014, 0.08395405858755112, 0.33615842461586, -0.005124587099999189, 1.3858871459960938, -0.41624024510383606, -0.06792216747999191, 0.2983757257461548, 0.21231384575366974, 0.6543921232223511, -1.843520998954773, 0.351342111825943, -1.013131022453308, -0.03491658717393875, 0.2746826410293579, -0.6124066710472107, -0.21598121523857117, 0.07827732712030411, -0.18868006765842438, 0.11325693130493164, -1.6732641458511353, -1.0742149353027344, 0.15047533810138702, -0.2706822454929352, 0.6182756423950195, -0.5376579761505127, 0.4419536888599396, 0.9979775547981262, -8.01710702944547e-05, -0.34362760186195374, 1.2654173374176025, -0.16981007158756256, -0.48054733872413635, 0.6912459135055542, -0.6626031994819641, -0.08096565306186676, 0.18935739994049072, -1.8396344184875488, -0.6384330987930298, -0.6475745439529419, -0.8829994201660156, 0.5036293864250183, 0.2629949152469635, -0.6192744374275208, 0.13119137287139893, 0.06775165349245071, -0.13195064663887024, -0.5711817741394043, 0.3065890669822693, -0.4124002158641815, 0.46052229404449463, 0.16278278827667236, 0.36992064118385315, -1.4331969022750854, -0.2478119283914566, 0.6254206895828247, -1.2886425256729126, -0.22830262780189514, 0.1981838345527649, 0.3197638988494873, -0.09843017160892487, -0.2952016294002533, -0.6947237849235535, 0.34806567430496216, -0.3122442662715912, -0.6666228771209717, 0.6453564763069153, -0.10350070893764496, -0.03413950651884079, -0.5424526333808899, 0.7820578217506409, 1.2924869060516357, 0.09157612174749374, 0.09557986259460449, -0.12149297446012497, -0.6464858651161194, -1.0642224550247192, -0.03382648155093193, 0.25556135177612305, -0.6870264410972595, 0.2877782881259918, 0.06554123014211655, -0.42244812846183777, -0.3739263415336609, -0.35396358370780945, 0.28208133578300476, -0.04505963996052742, 0.22228331863880157, -0.2973048686981201, -0.2971132695674896, -0.20536284148693085, -0.2616841197013855, -0.8480697870254517, 0.07906690984964371, 0.2881016433238983, -0.29105180501937866, 1.0354727506637573, 1.0971664190292358, 0.8235355615615845, -0.37308675050735474, -0.6394267678260803, -0.9406262040138245, -0.3414047956466675, -0.026550495997071266, 0.011970732361078262, -0.40209099650382996, -0.36487412452697754, 0.08537843823432922, 0.24994392693042755, 0.7774080634117126, -0.5960047245025635, -0.1767701953649521, -0.23424425721168518, -0.46658986806869507, 0.40000084042549133, 0.8696478009223938, 0.03904033824801445, 0.06901958584785461, -0.13913920521736145, 0.5866820812225342, -0.4087997376918793, 0.5375671982765198, 0.07793786376714706, -1.064713716506958, 0.012222635559737682, 0.10384431481361389, 0.008097008801996708, 0.13362936675548553, 0.7467359304428101, 0.16099190711975098, 0.23579207062721252, -0.28179216384887695, -0.14189283549785614, 0.49247393012046814, 0.20043537020683289, 0.14281590282917023, -0.5077271461486816, -0.35479646921157837, -0.39307811856269836, -0.7931295037269592, 0.11573491990566254, 0.02514616772532463, -0.023222792893648148, 0.15203650295734406, 0.6167893409729004, -0.2087707817554474, -0.26956886053085327, 0.422235369682312, -0.036826908588409424, -0.4588862955570221, 0.03270633891224861, -0.10106940567493439, 0.4298739731311798, -0.6018723249435425, 0.2724285125732422, -0.525924563407898, -0.5065925717353821, -0.10070765018463135, 0.7382825613021851, -0.031159061938524246, -0.4402030408382416, 0.9572052359580994, -0.6551192402839661, 0.12259186059236526, -0.4671074151992798, -0.21867205202579498, 0.10852788388729095, 0.2100231945514679, -0.12940935790538788, 0.207979217171669, -0.15334691107273102, 0.15364672243595123, 0.49508118629455566, 0.011411430314183235, 0.09823483228683472, -0.054107051342725754, 0.008963619358837605, 0.12270919233560562, 0.23244401812553406, 0.18004395067691803, -0.06648212671279907, 0.02520591765642166, 0.4420541226863861, -0.08115142583847046, 0.07090878486633301, -0.2630368769168854, -0.5921692252159119, 0.2861429452896118, 0.09047992527484894, -0.2831847667694092, -0.45392900705337524, 0.3405632972717285, -0.21615129709243774, 0.019999999552965164], "sample_rate": 48000}}]}, "weights": [], "sample_rate": 48000} \ No newline at end of file diff --git a/tools/run_tests.cpp b/tools/run_tests.cpp index 4080e033..0455e609 100644 --- a/tools/run_tests.cpp +++ b/tools/run_tests.cpp @@ -28,6 +28,7 @@ #include "test/test_wavenet_configurable_gating.cpp" #include "test/test_noncontiguous_blocks.cpp" #include "test/test_extensible.cpp" +#include "test/test_container.cpp" int main() { @@ -268,6 +269,18 @@ int main() // Extensibility: external architecture registration and get_dsp (issue #230) test_extensible::run_extensibility_tests(); + // Container / SlimmableContainer tests + test_container::test_container_loads_from_json(); + test_container::test_container_processes_audio(); + test_container::test_container_slimmable_selects_submodel(); + test_container::test_container_boundary_values(); + test_container::test_container_empty_submodels_throws(); + test_container::test_container_last_max_value_must_cover_one(); + test_container::test_container_unsorted_submodels_throws(); + test_container::test_container_sample_rate_mismatch_throws(); + test_container::test_container_load_from_file(); + test_container::test_container_default_is_max_size(); + std::cout << "Success!" << std::endl; #ifdef ADDASSERT std::cerr << "===============================================================" << std::endl; diff --git a/tools/test/test_container.cpp b/tools/test/test_container.cpp new file mode 100644 index 00000000..df5279e3 --- /dev/null +++ b/tools/test/test_container.cpp @@ -0,0 +1,313 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "json.hpp" + +#include "NAM/container.h" +#include "NAM/get_dsp.h" + +namespace test_container +{ + +// Helper: load a .nam file as JSON +nlohmann::json load_nam_json(const std::string& path) +{ + std::ifstream f(path); + if (!f.is_open()) + throw std::runtime_error("Cannot open " + path); + nlohmann::json j; + f >> j; + return j; +} + +// Build a SlimmableContainer JSON from 3 .nam files +nlohmann::json build_container_json(const std::string& small_path, const std::string& medium_path, + const std::string& large_path) +{ + nlohmann::json small_model = load_nam_json(small_path); + nlohmann::json medium_model = load_nam_json(medium_path); + nlohmann::json large_model = load_nam_json(large_path); + + nlohmann::json container; + container["version"] = "0.6.1"; + container["architecture"] = "SlimmableContainer"; + container["config"]["submodels"] = nlohmann::json::array( + {{{"max_value", 0.33}, {"model", small_model}}, {{"max_value", 0.66}, {"model", medium_model}}, {{"max_value", 1.0}, {"model", large_model}}}); + container["weights"] = nlohmann::json::array(); + container["sample_rate"] = 48000; + return container; +} + +// Helper to process audio through a DSP model and verify finite output +void process_and_verify(nam::DSP* dsp, int num_buffers, int buffer_size) +{ + const double sample_rate = dsp->GetExpectedSampleRate() > 0 ? dsp->GetExpectedSampleRate() : 48000.0; + dsp->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size); + std::vector output(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr = output.data(); + + for (int buf = 0; buf < num_buffers; buf++) + { + for (int i = 0; i < buffer_size; i++) + input[i] = (NAM_SAMPLE)(0.1 * ((buf * buffer_size + i) % 100) / 100.0); + + dsp->process(&in_ptr, &out_ptr, buffer_size); + + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + } +} + +// ===================================================================== +// Tests +// ===================================================================== + +void test_container_loads_from_json() +{ + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto dsp = nam::get_dsp(j); + assert(dsp != nullptr); +} + +void test_container_processes_audio() +{ + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto dsp = nam::get_dsp(j); + process_and_verify(dsp.get(), 3, 64); +} + +void test_container_slimmable_selects_submodel() +{ + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto dsp = nam::get_dsp(j); + const double sample_rate = 48000.0; + const int buffer_size = 64; + dsp->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.1); + std::vector out_small(buffer_size); + std::vector out_large(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr; + + // Process at minimum size (selects first submodel) + dsp->SetSlimmableSize(0.0); + out_ptr = out_small.data(); + dsp->process(&in_ptr, &out_ptr, buffer_size); + + // Process at maximum size (selects last submodel) + dsp->SetSlimmableSize(1.0); + out_ptr = out_large.data(); + dsp->process(&in_ptr, &out_ptr, buffer_size); + + // The outputs should differ since different models are active + // (Not guaranteed for every sample, but statistically they should differ) + bool any_different = false; + for (int i = 0; i < buffer_size; i++) + { + if (std::abs(out_small[i] - out_large[i]) > 1e-6) + { + any_different = true; + break; + } + } + assert(any_different); +} + +void test_container_boundary_values() +{ + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto dsp = nam::get_dsp(j); + const double sample_rate = 48000.0; + const int buffer_size = 16; + dsp->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.05); + std::vector output(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr = output.data(); + + // Test exact boundary values + dsp->SetSlimmableSize(0.33); // Should select first submodel (max_value=0.33) + dsp->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + + dsp->SetSlimmableSize(0.34); // Should select second submodel (max_value=0.66) + dsp->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + + dsp->SetSlimmableSize(0.66); // Should select second submodel (max_value=0.66) + dsp->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + + dsp->SetSlimmableSize(1.0); // Should select third submodel (max_value=1.0) + dsp->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); +} + +void test_container_empty_submodels_throws() +{ + nlohmann::json j; + j["version"] = "0.6.1"; + j["architecture"] = "SlimmableContainer"; + j["config"]["submodels"] = nlohmann::json::array(); + j["weights"] = nlohmann::json::array(); + j["sample_rate"] = 48000; + + bool threw = false; + try + { + auto dsp = nam::get_dsp(j); + } + catch (const std::runtime_error&) + { + threw = true; + } + assert(threw); +} + +void test_container_last_max_value_must_cover_one() +{ + // Build a container where last max_value < 1.0 + auto small_json = load_nam_json("example_models/lstm.nam"); + + nlohmann::json j; + j["version"] = "0.6.1"; + j["architecture"] = "SlimmableContainer"; + j["config"]["submodels"] = nlohmann::json::array({{{"max_value", 0.5}, {"model", small_json}}}); + j["weights"] = nlohmann::json::array(); + j["sample_rate"] = 48000; + + // Suppress the version warning + std::streambuf* originalCerr = std::cerr.rdbuf(); + std::ostringstream nullStream; + std::cerr.rdbuf(nullStream.rdbuf()); + + bool threw = false; + try + { + auto dsp = nam::get_dsp(j); + } + catch (const std::runtime_error&) + { + threw = true; + } + assert(threw); + + std::cerr.rdbuf(originalCerr); +} + +void test_container_unsorted_submodels_throws() +{ + auto small_json = load_nam_json("example_models/lstm.nam"); + auto medium_json = load_nam_json("example_models/wavenet.nam"); + + nlohmann::json j; + j["version"] = "0.6.1"; + j["architecture"] = "SlimmableContainer"; + j["config"]["submodels"] = nlohmann::json::array( + {{{"max_value", 0.8}, {"model", small_json}}, {{"max_value", 0.5}, {"model", medium_json}}}); + j["weights"] = nlohmann::json::array(); + j["sample_rate"] = 48000; + + std::streambuf* originalCerr = std::cerr.rdbuf(); + std::ostringstream nullStream; + std::cerr.rdbuf(nullStream.rdbuf()); + + bool threw = false; + try + { + auto dsp = nam::get_dsp(j); + } + catch (const std::runtime_error&) + { + threw = true; + } + assert(threw); + + std::cerr.rdbuf(originalCerr); +} + +void test_container_sample_rate_mismatch_throws() +{ + // Create two models with different sample rates + auto model_48k = load_nam_json("example_models/lstm.nam"); + auto model_44k = load_nam_json("example_models/lstm.nam"); + model_44k["sample_rate"] = 44100; + + nlohmann::json j; + j["version"] = "0.6.1"; + j["architecture"] = "SlimmableContainer"; + j["config"]["submodels"] = nlohmann::json::array( + {{{"max_value", 0.5}, {"model", model_44k}}, {{"max_value", 1.0}, {"model", model_48k}}}); + j["weights"] = nlohmann::json::array(); + j["sample_rate"] = 48000; + + std::streambuf* originalCerr = std::cerr.rdbuf(); + std::ostringstream nullStream; + std::cerr.rdbuf(nullStream.rdbuf()); + + bool threw = false; + try + { + auto dsp = nam::get_dsp(j); + } + catch (const std::runtime_error&) + { + threw = true; + } + assert(threw); + + std::cerr.rdbuf(originalCerr); +} + +void test_container_load_from_file() +{ + std::filesystem::path path("example_models/slimmable_container.nam"); + auto dsp = nam::get_dsp(path); + assert(dsp != nullptr); + process_and_verify(dsp.get(), 3, 64); +} + +void test_container_default_is_max_size() +{ + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto dsp = nam::get_dsp(j); + const double sample_rate = 48000.0; + const int buffer_size = 64; + dsp->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.1); + std::vector out_default(buffer_size); + std::vector out_max(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr; + + // Process with default (should be max size) + out_ptr = out_default.data(); + dsp->process(&in_ptr, &out_ptr, buffer_size); + + // Explicitly set to max + dsp->SetSlimmableSize(1.0); + out_ptr = out_max.data(); + dsp->process(&in_ptr, &out_ptr, buffer_size); + + // Both should produce the same output (same model active) + for (int i = 0; i < buffer_size; i++) + assert(std::abs(out_default[i] - out_max[i]) < 1e-6); +} + +} // namespace test_container From 568160406b107dd5cf535ced670c4fbdbd952658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Felipe=20Santos?= Date: Mon, 9 Mar 2026 11:15:56 -0700 Subject: [PATCH 2/5] Fixed model in container tests --- tools/test/test_container.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/test/test_container.cpp b/tools/test/test_container.cpp index df5279e3..50ddc386 100644 --- a/tools/test/test_container.cpp +++ b/tools/test/test_container.cpp @@ -73,21 +73,21 @@ void process_and_verify(nam::DSP* dsp, int num_buffers, int buffer_size) void test_container_loads_from_json() { - auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/wavenet_a2_max.nam"); auto dsp = nam::get_dsp(j); assert(dsp != nullptr); } void test_container_processes_audio() { - auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/wavenet_a2_max.nam"); auto dsp = nam::get_dsp(j); process_and_verify(dsp.get(), 3, 64); } void test_container_slimmable_selects_submodel() { - auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/wavenet_a2_max.nam"); auto dsp = nam::get_dsp(j); const double sample_rate = 48000.0; const int buffer_size = 64; @@ -125,7 +125,7 @@ void test_container_slimmable_selects_submodel() void test_container_boundary_values() { - auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/wavenet_a2_max.nam"); auto dsp = nam::get_dsp(j); const double sample_rate = 48000.0; const int buffer_size = 16; @@ -284,7 +284,7 @@ void test_container_load_from_file() void test_container_default_is_max_size() { - auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/nano_relu.nam"); + auto j = build_container_json("example_models/lstm.nam", "example_models/wavenet.nam", "example_models/wavenet_a2_max.nam"); auto dsp = nam::get_dsp(j); const double sample_rate = 48000.0; const int buffer_size = 64; From f6d3c5ac3cfa7c85fd2396f541351b3dec90f325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Felipe=20Santos?= Date: Tue, 10 Mar 2026 16:25:22 -0700 Subject: [PATCH 3/5] Added a --slim parameter to render --- tools/render.cpp | 57 ++++++++++++-- tools/run_tests.cpp | 7 ++ tools/test/test_render_slim.cpp | 135 ++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 tools/test/test_render_slim.cpp diff --git a/tools/render.cpp b/tools/render.cpp index 77836b41..8d491136 100644 --- a/tools/render.cpp +++ b/tools/render.cpp @@ -2,11 +2,14 @@ #include #include #include +#include #include #include #include +#include #include +#include "NAM/container.h" #include "NAM/dsp.h" #include "NAM/get_dsp.h" #include "wav.h" @@ -60,15 +63,47 @@ bool SaveWavFloat32(const char* fileName, const float* samples, size_t numSample int main(int argc, char* argv[]) { - if (argc < 3 || argc > 4) + // Parse optional --slim from the arguments + double slimValue = -1.0; + bool hasSlim = false; + std::vector positionalArgs; + positionalArgs.push_back(argv[0]); + + for (int i = 1; i < argc; i++) + { + std::string arg(argv[i]); + if (arg == "--slim") + { + if (i + 1 >= argc) + { + std::cerr << "Error: --slim requires a value between 0.0 and 1.0\n"; + return 1; + } + char* end = nullptr; + slimValue = std::strtod(argv[i + 1], &end); + if (end == argv[i + 1] || *end != '\0' || slimValue < 0.0 || slimValue > 1.0) + { + std::cerr << "Error: --slim value must be a number between 0.0 and 1.0\n"; + return 1; + } + hasSlim = true; + i++; // skip the value + } + else + { + positionalArgs.push_back(argv[i]); + } + } + + if (positionalArgs.size() < 3 || positionalArgs.size() > 4) { - std::cerr << "Usage: render [output.wav]\n"; + std::cerr << "Usage: render [--slim <0.0-1.0>] [output.wav]\n"; return 1; } - const char* modelPath = argv[1]; - const char* inputPath = argv[2]; - const char* outputPath = (argc >= 4) ? argv[3] : "output.wav"; + const char* modelPath = positionalArgs[1]; + const char* inputPath = positionalArgs[2]; + const char* outputPath = (positionalArgs.size() >= 4) ? positionalArgs[3] : "output.wav"; std::cerr << "Loading model [" << modelPath << "]\n"; auto model = nam::get_dsp(std::filesystem::path(modelPath)); @@ -79,6 +114,18 @@ int main(int argc, char* argv[]) } std::cerr << "Model loaded successfully\n"; + if (hasSlim) + { + auto* container = dynamic_cast(model.get()); + if (!container) + { + std::cerr << "Error: --slim requires a model that implements the Slimmable interface (e.g. SlimmableContainer)\n"; + return 1; + } + std::cerr << "Setting slimmable size to " << slimValue << "\n"; + model->SetSlimmableSize(slimValue); + } + std::vector inputAudio; double inputSampleRate = 0.0; auto loadResult = dsp::wav::Load(inputPath, inputAudio, inputSampleRate); diff --git a/tools/run_tests.cpp b/tools/run_tests.cpp index 0455e609..d01f8938 100644 --- a/tools/run_tests.cpp +++ b/tools/run_tests.cpp @@ -29,6 +29,7 @@ #include "test/test_noncontiguous_blocks.cpp" #include "test/test_extensible.cpp" #include "test/test_container.cpp" +#include "test/test_render_slim.cpp" int main() { @@ -281,6 +282,12 @@ int main() test_container::test_container_load_from_file(); test_container::test_container_default_is_max_size(); + // Render --slim tests + test_render_slim::test_slim_changes_output(); + test_render_slim::test_slim_rejects_non_slimmable(); + test_render_slim::test_slim_boundary_values(); + test_render_slim::test_slim_applied_before_processing(); + std::cout << "Success!" << std::endl; #ifdef ADDASSERT std::cerr << "===============================================================" << std::endl; diff --git a/tools/test/test_render_slim.cpp b/tools/test/test_render_slim.cpp new file mode 100644 index 00000000..8b05ef41 --- /dev/null +++ b/tools/test/test_render_slim.cpp @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "NAM/container.h" +#include "NAM/dsp.h" +#include "NAM/get_dsp.h" + +namespace test_render_slim +{ + +// Test that --slim with a SlimmableContainer model changes the output +void test_slim_changes_output() +{ + std::cout << " test_slim_changes_output" << std::endl; + + // Load the slimmable container model + auto model = nam::get_dsp(std::filesystem::path("example_models/slimmable_container.nam")); + assert(model != nullptr); + + // Verify it's actually a ContainerModel + auto* container = dynamic_cast(model.get()); + assert(container != nullptr); + + const double sample_rate = model->GetExpectedSampleRate() > 0 ? model->GetExpectedSampleRate() : 48000.0; + const int buffer_size = 64; + model->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.1); + std::vector out_small(buffer_size); + std::vector out_large(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr; + + // Render at minimum size + model->SetSlimmableSize(0.0); + out_ptr = out_small.data(); + model->process(&in_ptr, &out_ptr, buffer_size); + + // Render at maximum size + model->SetSlimmableSize(1.0); + out_ptr = out_large.data(); + model->process(&in_ptr, &out_ptr, buffer_size); + + // Outputs should differ since different submodels are active + bool any_different = false; + for (int i = 0; i < buffer_size; i++) + { + if (std::abs(out_small[i] - out_large[i]) > 1e-6) + { + any_different = true; + break; + } + } + assert(any_different); +} + +// Test that --slim rejects non-slimmable models +void test_slim_rejects_non_slimmable() +{ + std::cout << " test_slim_rejects_non_slimmable" << std::endl; + + // Load a regular (non-container) model + auto model = nam::get_dsp(std::filesystem::path("example_models/lstm.nam")); + assert(model != nullptr); + + // Verify it's NOT a ContainerModel + auto* container = dynamic_cast(model.get()); + assert(container == nullptr); +} + +// Test that --slim with boundary values produces finite output +void test_slim_boundary_values() +{ + std::cout << " test_slim_boundary_values" << std::endl; + + auto model = nam::get_dsp(std::filesystem::path("example_models/slimmable_container.nam")); + assert(model != nullptr); + + const double sample_rate = model->GetExpectedSampleRate() > 0 ? model->GetExpectedSampleRate() : 48000.0; + const int buffer_size = 64; + model->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.05); + std::vector output(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr = output.data(); + + double values[] = {0.0, 0.25, 0.5, 0.75, 1.0}; + for (double val : values) + { + model->SetSlimmableSize(val); + model->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + } +} + +// Test that SetSlimmableSize is called before processing (simulates --slim flow) +void test_slim_applied_before_processing() +{ + std::cout << " test_slim_applied_before_processing" << std::endl; + + auto model = nam::get_dsp(std::filesystem::path("example_models/slimmable_container.nam")); + assert(model != nullptr); + + auto* container = dynamic_cast(model.get()); + assert(container != nullptr); + + const double sample_rate = model->GetExpectedSampleRate() > 0 ? model->GetExpectedSampleRate() : 48000.0; + const int buffer_size = 64; + + // Set slim BEFORE Reset (as render.cpp does it before Reset) + model->SetSlimmableSize(0.5); + model->Reset(sample_rate, buffer_size); + + std::vector input(buffer_size, 0.1); + std::vector output(buffer_size); + NAM_SAMPLE* in_ptr = input.data(); + NAM_SAMPLE* out_ptr = output.data(); + + model->process(&in_ptr, &out_ptr, buffer_size); + + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); +} + +} // namespace test_render_slim From 9d65c5df2baa163712407c4b993e79883920dbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Felipe=20Santos?= Date: Wed, 11 Mar 2026 10:37:59 -0700 Subject: [PATCH 4/5] SlimmableModel is now an interface. Bumped NAM file version to 0.7.0. Made max_value exclusive in SetSlimmableSize. --- NAM/container.cpp | 2 +- NAM/container.h | 6 ++-- NAM/dsp.h | 7 ----- NAM/get_dsp.cpp | 2 +- NAM/get_dsp.h | 2 +- NAM/slimmable.h | 21 ++++++++++++++ docs/nam_file_version.rst | 2 ++ example_models/slimmable_container.nam | 2 +- tools/render.cpp | 10 +++---- tools/test/test_container.cpp | 40 +++++++++++++++++--------- tools/test/test_render_slim.cpp | 29 ++++++++++--------- 11 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 NAM/slimmable.h diff --git a/NAM/container.cpp b/NAM/container.cpp index b5f4e128..8442e173 100644 --- a/NAM/container.cpp +++ b/NAM/container.cpp @@ -72,7 +72,7 @@ void ContainerModel::SetSlimmableSize(const double val) _active_index = _submodels.size() - 1; for (size_t i = 0; i < _submodels.size(); ++i) { - if (val <= _submodels[i].max_value) + if (val < _submodels[i].max_value) { _active_index = i; break; diff --git a/NAM/container.h b/NAM/container.h index 0a4b1a87..d69f03d0 100644 --- a/NAM/container.h +++ b/NAM/container.h @@ -6,6 +6,7 @@ #include "dsp.h" #include "model_config.h" +#include "slimmable.h" namespace nam { @@ -21,8 +22,9 @@ struct Submodel /// \brief A container model that holds multiple submodels at different sizes /// /// SetSlimmableSize selects the active submodel based on the max_value thresholds. -/// Each submodel covers values up to (and including) its max_value. -class ContainerModel : public DSP +/// Each submodel covers values up to (but not including) its max_value. +/// The last submodel is the fallback for values at or above the last threshold. +class ContainerModel : public DSP, public SlimmableModel { public: /// \brief Constructor diff --git a/NAM/dsp.h b/NAM/dsp.h index f41abc0c..15bc9b81 100644 --- a/NAM/dsp.h +++ b/NAM/dsp.h @@ -155,13 +155,6 @@ class DSP /// \param outputLevel Output level in dBu void SetOutputLevel(const double outputLevel); - /// \brief Set the slimmable size of the model - /// - /// This is a hint that allows models to reduce their computational cost. - /// The interpretation is model-specific. The default implementation is a no-op. - /// \param val Value between 0.0 (minimum size) and 1.0 (maximum size) - virtual void SetSlimmableSize(const double val) { (void)val; }; - protected: friend class wavenet::WaveNet; // Allow WaveNet to access protected members. Used in condition DSP. diff --git a/NAM/get_dsp.cpp b/NAM/get_dsp.cpp index 1518055f..73dd3ef0 100644 --- a/NAM/get_dsp.cpp +++ b/NAM/get_dsp.cpp @@ -69,7 +69,7 @@ void verify_config_version(const std::string versionStr) << currentVersion.toString(); throw std::runtime_error(ss.str()); } - else if (version.major == 0 && version.minor == 6 && version.patch > 0) + else if (currentVersion < version) { std::cerr << "Model config is a partially-supported version " << versionStr << ". The latest fully-supported version is " << currentVersion.toString() diff --git a/NAM/get_dsp.h b/NAM/get_dsp.h index e629b300..29fb2ec9 100644 --- a/NAM/get_dsp.h +++ b/NAM/get_dsp.h @@ -42,7 +42,7 @@ Version ParseVersion(const std::string& versionStr); void verify_config_version(const std::string versionStr); -const std::string LATEST_FULLY_SUPPORTED_NAM_FILE_VERSION = "0.6.0"; +const std::string LATEST_FULLY_SUPPORTED_NAM_FILE_VERSION = "0.7.0"; const std::string EARLIEST_SUPPORTED_NAM_FILE_VERSION = "0.5.0"; /// \brief Get NAM from a .nam file at the provided location diff --git a/NAM/slimmable.h b/NAM/slimmable.h new file mode 100644 index 00000000..af1cef52 --- /dev/null +++ b/NAM/slimmable.h @@ -0,0 +1,21 @@ +#pragma once + +namespace nam +{ + +/// \brief Interface for models that support dynamic size reduction +/// +/// Models implementing this interface can reduce their computational cost +/// at the expense of quality. The interpretation of the size parameter is +/// model-specific (e.g., selecting a sub-model, pruning channels, etc.). +class SlimmableModel +{ +public: + virtual ~SlimmableModel() = default; + + /// \brief Set the slimmable size of the model + /// \param val Value between 0.0 (minimum size) and 1.0 (maximum size) + virtual void SetSlimmableSize(const double val) = 0; +}; + +} // namespace nam diff --git a/docs/nam_file_version.rst b/docs/nam_file_version.rst index c102d084..8d19b779 100644 --- a/docs/nam_file_version.rst +++ b/docs/nam_file_version.rst @@ -31,3 +31,5 @@ The following table shows which versions of NeuralAmpModelerCore support which m - 0.5.3 * - 0.4.0 - 0.6.0 + * - 0.5.0 + - 0.7.0 diff --git a/example_models/slimmable_container.nam b/example_models/slimmable_container.nam index 5099a9c2..ce8b1315 100644 --- a/example_models/slimmable_container.nam +++ b/example_models/slimmable_container.nam @@ -1 +1 @@ -{"version": "0.6.1", "architecture": "SlimmableContainer", "config": {"submodels": [{"max_value": 0.33, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 44, "second": 41}, "loudness": -37.8406867980957, "gain": 0.13508800804658277, "name": "Test LSTM", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": null}}, "architecture": "LSTM", "config": {"input_size": 1, "hidden_size": 3, "num_layers": 1}, "weights": [-0.21677088737487793, -0.6683622002601624, -0.2560940980911255, -0.3588429093360901, 0.17952610552310944, 0.19445613026618958, -0.01662646047770977, 0.5353694558143616, -0.2536540627479553, -0.5132213234901428, -0.020476307719945908, 0.08592455089092255, -0.6891753673553467, 0.3627359867095947, 0.008421811275184155, 0.3113192617893219, 0.14251480996608734, 0.07989779114723206, -0.18211324512958527, 0.7118963003158569, 0.41084015369415283, -0.6571938395500183, -0.13214066624641418, -0.2698603868484497, 0.49387243390083313, -0.3491725027561188, 0.6353667974472046, -0.5005152225494385, 0.2052856683731079, -0.4301638901233673, -0.15770092606544495, -0.7181791067123413, 0.056290093809366226, -0.49049463868141174, 0.6623441576957703, 0.09029324352741241, 0.34005245566368103, 0.16416560113430023, 0.15520110726356506, -0.4155678153038025, -0.36928507685661316, 0.3211132884025574, -0.6769840121269226, -0.1575538069009781, 0.05268515646457672, -0.4191459119319916, 0.599330484867096, 0.21518059074878693, -4.246325492858887, -3.315647840499878, -4.328850746154785, 4.496089458465576, 5.015639305114746, 3.6492037773132324, 0.14431169629096985, -0.6633821725845337, 0.11673200130462646, -0.1418764889240265, -0.4897872805595398, -0.8689419031143188, -0.06714004278182983, -0.4450395107269287, -0.02142983116209507, -0.15136894583702087, -2.775207996368408, -0.08681213855743408, 0.05702732503414154, 0.670292317867279, 0.31442636251449585, 0.30793967843055725], "sample_rate": 48000}}, {"max_value": 0.66, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 32, "second": 27}, "loudness": -20.020729064941406, "gain": 0.19575619747898518, "name": "Test Model", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.13345033695550146}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 3, "kernel_size": 3, "dilations": [1, 2], "activation": "Tanh", "gated": false, "head_bias": false}, {"input_size": 3, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [8], "activation": "Tanh", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.6180188059806824, 1.0314024686813354, -1.0111560821533203, -0.38462021946907043, 0.35968291759490967, 0.5255971550941467, 0.19149275124073029, -0.18075695633888245, -0.33711034059524536, -0.21037575602531433, 0.2007753700017929, 0.21644853055477142, -1.3216396570205688, -0.35082393884658813, 0.43541353940963745, 0.9693092107772827, 0.2394428700208664, -0.41078877449035645, -1.193748116493225, -0.14876757562160492, 0.8413559198379517, 0.24491633474826813, 0.8857091665267944, 0.5647665858268738, 0.08301573246717453, -0.801490843296051, 0.168976828455925, -0.5413634181022644, 0.484220415353775, 0.021656272932887077, -0.15155009925365448, 0.07081033289432526, 0.00019397131109144539, -0.7408013939857483, -1.3308452367782593, -1.0403972864151, 0.016809873282909393, 0.6778652667999268, 0.28265541791915894, -0.28287461400032043, 1.0525944232940674, -0.6385797262191772, -0.2195468544960022, -0.3150196671485901, -0.8814508318901062, -0.2746180295944214, 0.15367186069488525, 0.22431065142154694, -0.056788790971040726, -0.38902369141578674, 0.5406259894371033, 0.3566059470176697, 0.14383991062641144, -0.25409433245658875, 0.16139137744903564, -0.05857989564538002, -0.18448838591575623, -0.253485769033432, -0.42405444383621216, -0.030114537104964256, 0.47283637523651123, 0.14930365979671478, -0.4410354793071747, -0.21976807713508606, -0.12736600637435913, -0.5674286484718323, -0.347588449716568, -0.3687525689601898, 0.4130803942680359, 0.8551775217056274, -0.05746064335107803, -0.38243237137794495, 0.20036561787128448, 0.25542038679122925, -0.0819990262389183, 0.19469600915908813, 0.10215214639902115, -0.26087674498558044, -0.1773151010274887, -0.09658292680978775, -0.7381710410118103, 0.7003506422042847, 0.7253592014312744, -0.07488955557346344, -0.23439547419548035, -0.5138604044914246, -0.7976311445236206, -0.8090851902961731, -0.37562188506126404, -1.163352131843567, 0.30907657742500305, 0.0564480796456337, 0.1190297082066536, 0.2310808300971985, -0.45360898971557617, -0.11524498462677002, 0.2552330493927002, 0.2913571298122406, -0.23171702027320862, -0.35578709840774536, 0.40732908248901367, 0.7458747029304504, 0.27514976263046265, -0.7503036856651306, -0.6707972884178162, -0.4248569905757904, -0.1671624332666397, -0.14162226021289825, 0.37550851702690125, -0.038120146840810776, 0.16232982277870178, -0.05173371359705925, -0.2842361629009247, 0.38820165395736694, 0.521754801273346, -0.3581869900226593, 0.21531476080417633, 0.11342520266771317, 0.01764630153775215, 0.07780527323484421, 0.9356631636619568, 0.04235581308603287, -0.3450177311897278, 0.3345951437950134, -0.678291380405426, -0.4191069006919861, -0.1770099401473999, -5.386871337890625, -5.130850791931152, -0.4049331247806549, 0.019999999552965164], "sample_rate": 48000}}, {"max_value": 1.0, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2026, "month": 1, "day": 18, "hour": 19, "minute": 28, "second": 2}, "loudness": -25.50621795654297, "gain": 0.8174147104354939, "name": "Atrisan 100 HT Pedal Jump Chan Voice 4 Blend 50 - Nuvo N22", "modeled_by": "tone3000", "gear_type": "amp", "gear_make": "tz-make", "gear_model": "tz-model", "tone_type": "overdrive", "input_level_dbu": 8.25, "output_level_dbu": 4, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [335], "safety_factor": 1, "recommended": 334, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.05744442289189271}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 4, "kernel_size": 3, "dilations": [1, 2, 4, 8, 16, 32, 64], "activation": "ReLU", "gated": false, "head_bias": false}, {"input_size": 4, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512], "activation": "ReLU", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.43676555156707764, 0.18804845213890076, -1.191544771194458, -1.2514153718948364, 0.1522054672241211, 0.2674163281917572, 0.11941885948181152, -0.016747985035181046, -0.24142038822174072, -0.08158593624830246, 0.1658506542444229, 0.12450455874204636, -0.1257639080286026, 0.05097454413771629, 0.06655367463827133, 0.15613363683223724, 0.3628908693790436, 0.16920273005962372, -0.4865663945674896, -0.33004868030548096, 0.1686093509197235, 0.4942941963672638, 0.14733701944351196, 0.1264810413122177, -0.3330173194408417, 0.2558712959289551, 0.1980869621038437, -0.5377613306045532, -0.44927188754081726, -0.10965251177549362, -0.2049286812543869, 0.5187842845916748, -0.11666373908519745, -0.010038944892585278, -0.4929092228412628, -0.3522462546825409, -0.30443158745765686, -0.05553298071026802, 0.032637786120176315, -0.01095358282327652, -0.2228831946849823, -0.07661055028438568, 0.18166741728782654, -0.02288321778178215, -0.2550153434276581, -0.27006709575653076, -0.05640152841806412, 0.2399696558713913, 0.01374511606991291, -0.2519863247871399, 0.25369852781295776, 0.43098628520965576, 0.24656431376934052, 0.05089268833398819, 0.2244647890329361, -0.3239988088607788, 0.026821687817573547, -0.5183702707290649, -0.549621045589447, -0.6563447117805481, -0.17373943328857422, -0.32807308435440063, 0.2662317454814911, -0.5284045934677124, 0.4098321795463562, -0.1177985891699791, -0.3497377634048462, 0.06472523510456085, 0.2881721258163452, 0.4962410628795624, -0.4693456292152405, 0.22105255722999573, 0.5390405058860779, 0.6857721209526062, 0.13449627161026, -0.22106148302555084, -0.015273668803274632, -0.15233269333839417, 0.0054369233548641205, -0.2990502715110779, -0.6390000581741333, 0.09520208835601807, 0.5206401348114014, -0.30539414286613464, 0.005384453106671572, -0.11123053729534149, -0.3819287419319153, -0.2212216705083847, 0.4531766176223755, -0.6183855533599854, -0.07028502225875854, 0.5584202408790588, 0.03141379728913307, 0.03053859807550907, 0.08987420797348022, 0.10635538399219513, -0.004241787828505039, -0.2514967918395996, 0.4621999263763428, -0.24512320756912231, 0.020135050639510155, 0.42594560980796814, -0.3939764201641083, -0.4036279320716858, -0.6264017820358276, 0.12763042747974396, -0.11675230413675308, -0.3192313015460968, -0.0003565576334949583, -0.06628905236721039, -0.3489648103713989, -0.18046769499778748, -0.042343053966760635, 0.20209242403507233, -0.044064972549676895, 0.010927309282124043, -0.4592772126197815, -0.2547818720340729, 0.4999264180660248, -0.04825885593891144, 0.2511541247367859, -0.05963046848773956, -0.4923741817474365, -0.19782790541648865, 0.18921701610088348, -0.143302783370018, -0.417974591255188, 0.4820250868797302, -0.01435916032642126, -0.09722636640071869, 0.04334542900323868, 0.20531202852725983, -0.6767648458480835, -0.03919640928506851, 0.41943681240081787, -0.705767810344696, 1.0928969383239746, 0.008152804337441921, 0.30072590708732605, 0.700724720954895, 1.4694486856460571, -0.36657166481018066, 0.29822444915771484, 0.08182942867279053, -1.1029194593429565, 0.39373770356178284, 0.572385847568512, -0.10765771567821503, 0.6150015592575073, 0.7301293611526489, -0.8640158772468567, -0.6661192178726196, -0.17441526055335999, 0.23340773582458496, 0.2347957193851471, -0.5018205642700195, 0.04749491065740585, -0.25646737217903137, -0.12705065310001373, -0.2656175196170807, -0.14754967391490936, -0.16251829266548157, -0.26762738823890686, -0.2506292164325714, -0.023960385471582413, 0.08543525636196136, -0.051170505583286285, 0.24774709343910217, -0.29134371876716614, 0.25539499521255493, 0.19203688204288483, -0.09644774347543716, 0.045086562633514404, 0.2614458203315735, -0.14013680815696716, 0.5095819234848022, 0.1808817982673645, 0.13184405863285065, 0.2857828140258789, -0.2877650856971741, 0.025841550901532173, -0.10298394411802292, 0.4531080424785614, 0.19967995584011078, -0.0035516824573278427, 0.6057309508323669, -0.01614478975534439, -0.024831678718328476, -0.23062309622764587, 0.0057058511301875114, -0.22100116312503815, 0.6274505257606506, -0.09544087946414948, -0.47833094000816345, -0.07983476668596268, -0.32524535059928894, -0.9022202491760254, 0.17296163737773895, 0.1715262085199356, 0.44342607259750366, 0.0672280341386795, 0.3143714964389801, -0.16193732619285583, -0.5337017774581909, -0.23426392674446106, 0.31633561849594116, 0.16039276123046875, 0.3396058678627014, 0.1790986955165863, 0.22826147079467773, 0.565819501876831, -0.18677009642124176, 0.11501625180244446, -0.9280168414115906, -0.5102543234825134, 0.4280734062194824, -0.4131118953227997, -0.3216524124145508, -0.9526995420455933, -0.8283767700195312, -0.02265196479856968, 0.3181364834308624, -0.13400879502296448, -0.3635147213935852, -0.07217840850353241, 0.5390769839286804, 0.022873638197779655, 0.15108828246593475, 0.06688182055950165, -0.06298623979091644, -0.04183664545416832, 0.26526492834091187, -0.20283886790275574, 0.8089739084243774, 0.39357757568359375, -0.4892053008079529, -0.4210922122001648, 0.0030071621295064688, 0.1889152228832245, -0.3113728165626526, 0.04760019853711128, 0.5401822924613953, -0.31828656792640686, -0.022103704512119293, -0.7838840484619141, 0.23758691549301147, 0.6584234237670898, -0.14207355678081512, 0.3508256673812866, 0.24494409561157227, 0.37631094455718994, -0.036634355783462524, 1.0158957242965698, -0.4377710223197937, -0.2699510157108307, 0.011075957678258419, -0.9512584209442139, 1.0744872093200684, 0.07266976684331894, -0.5702192783355713, -0.22477132081985474, 0.10158557444810867, 0.5408655405044556, -0.05424047261476517, -0.22979958355426788, 0.12589116394519806, -0.3061460554599762, -0.007357880473136902, 0.160592719912529, -0.8183864951133728, -0.1873759627342224, 0.4029034972190857, 0.20340028405189514, -0.19033348560333252, -0.6387582421302795, 0.3744193911552429, 0.4734930992126465, -0.7402716279029846, 0.16290104389190674, 0.231669083237648, 0.22414864599704742, 0.003755988087505102, -0.0671466663479805, 0.1964668184518814, 0.014198299497365952, 0.163277730345726, -0.26071494817733765, 0.35350218415260315, -0.686671793460846, 0.459243506193161, -0.09164588153362274, 0.7604275345802307, 0.4730943739414215, 0.35176384449005127, 0.44463688135147095, 0.035675011575222015, 0.2871439754962921, -0.21191704273223877, 0.8446514010429382, -0.881138026714325, -0.5140098929405212, -0.2590724527835846, -0.6394899487495422, 1.0582557916641235, 0.19049172103405, -0.007477824576199055, -0.0690576359629631, 0.10438528656959534, 0.46519139409065247, 0.2671721279621124, -0.8850185871124268, -0.07695616781711578, 0.06778068840503693, 0.09831968694925308, 0.425837904214859, 0.21560505032539368, -0.0973641574382782, 0.11831096559762955, 0.2720680832862854, -0.8112271428108215, 0.0679216980934143, 0.0034201480448246002, -1.1940691471099854, 0.015147575177252293, 0.2989473044872284, 0.4385072588920593, 0.22488915920257568, -0.07610563188791275, 0.24487024545669556, 0.16010652482509613, -0.1590120494365692, -0.8069810271263123, 0.3454744517803192, 0.10192205011844635, -0.5487010478973389, 0.08557324856519699, -0.0033477218821644783, -0.40646129846572876, -0.3718165159225464, 0.07761954516172409, -0.1472809761762619, -0.39236438274383545, -0.04602040350437164, -0.2916988134384155, -0.35268932580947876, 0.44220033288002014, 1.061747431755066, 0.01184292882680893, 0.029237236827611923, -0.3696916997432709, -0.3326391875743866, 0.3186306059360504, -0.0686657726764679, -0.12802480161190033, 0.059870608150959015, 0.4420037567615509, -0.11589302867650986, 0.10948559641838074, 0.3228295147418976, 0.30819857120513916, -0.5482281446456909, -1.5860124826431274, -1.1525928974151611, 0.501322865486145, 0.24488481879234314, 0.3214830756187439, 0.46026182174682617, -1.3560254573822021, -0.6456385850906372, -0.7880288362503052, 0.8956019878387451, 0.41244542598724365, -0.6440726518630981, -0.7221627235412598, -0.25085917115211487, -0.7078524231910706, 0.4188958704471588, 0.45524659752845764, 0.3029322028160095, -0.22305667400360107, 0.44652125239372253, 0.24373604357242584, 0.3368196487426758, 0.1511261910200119, 0.2610892951488495, -0.012466066516935825, 0.519991397857666, 0.3664250671863556, 0.04987747222185135, -0.04385135695338249, -0.2866438329219818, -0.016423135995864868, -0.6226651668548584, -0.07403579354286194, -0.25110307335853577, 0.13762260973453522, 0.3649454116821289, -0.04414776712656021, -0.02799362502992153, 0.39993947744369507, -0.059658318758010864, -0.5658756494522095, -0.38595327734947205, 0.12831152975559235, -0.6940039396286011, -0.21010565757751465, 0.0833023339509964, 0.2953319549560547, -0.2192569226026535, -9.963240881916136e-05, -0.4918636083602905, -0.35004717111587524, -0.11263000965118408, 0.5789287090301514, 0.333292156457901, 0.03616069629788399, -0.723102331161499, 0.07424107939004898, 0.27536284923553467, -0.3164575397968292, 0.4204881191253662, -0.10002204775810242, 0.045674219727516174, 0.4877814054489136, -0.13877654075622559, -0.9487224817276001, -0.5420687794685364, 0.15843534469604492, -0.8356834053993225, -0.3401522934436798, -0.021845858544111252, 0.24137890338897705, 0.6131256222724915, -0.5279566645622253, 0.4040375053882599, -0.287713885307312, -0.32596370577812195, -0.289026141166687, -0.8558264970779419, -0.8393163681030273, -0.6748902797698975, -1.5344449281692505, -0.48501765727996826, 0.7561529278755188, -0.5639386773109436, 0.2747798264026642, 0.31883418560028076, 0.46465715765953064, 0.8148818016052246, -1.0762479305267334, 0.5226246118545532, 0.8592436909675598, 0.05685063451528549, -1.098716378211975, 1.0224401950836182, 1.6439732313156128, 0.15941590070724487, 0.33981525897979736, -0.736503005027771, -0.1396108865737915, -0.3593847453594208, 0.18113897740840912, 0.3901767134666443, 0.24246807396411896, -0.3559393584728241, 0.3014945983886719, 0.5807337760925293, 0.632666289806366, -0.3279235064983368, -0.3521895110607147, 0.21897214651107788, 0.2008153200149536, 0.18349437415599823, 0.2843616306781769, -0.07296476513147354, 0.0050212121568620205, 0.1398988664150238, -0.04363537207245827, -0.10488884150981903, 0.018994251266121864, -0.8944122195243835, -0.1002153530716896, -0.12303996831178665, -0.6947574019432068, -0.20797944068908691, -0.25055378675460815, 0.8080053925514221, -0.1779334545135498, -0.21596449613571167, -0.5812117457389832, 0.07938572019338608, 0.31331679224967957, 1.3328310251235962, -0.1157936379313469, -0.20552347600460052, 0.2777186930179596, -0.4894363582134247, 0.1485048085451126, 0.2016707956790924, 0.12642067670822144, -0.6121338605880737, 0.07307889312505722, 0.5374605655670166, 0.6080096960067749, -0.7628602981567383, -0.4795125722885132, 0.14357036352157593, 0.03981512784957886, -0.47786933183670044, 0.548004150390625, -0.4770188629627228, -0.007587160915136337, 0.4921312630176544, -1.8222495317459106, 0.8633298873901367, -0.24518749117851257, -1.1610788106918335, -0.7625094652175903, 0.562911331653595, 0.8363901376724243, -0.5850722789764404, 0.18943746387958527, -0.19145213067531586, 0.5438283085823059, 0.27744850516319275, -0.8637493848800659, 1.191653847694397, -0.6768492460250854, -0.30685824155807495, -1.0220935344696045, 1.1770503520965576, 1.064857840538025, -0.09791866689920425, -0.49691858887672424, -0.18965063989162445, 0.18372981250286102, -0.180926114320755, -0.11052561551332474, -0.14311599731445312, -0.0899554044008255, -0.23982501029968262, -0.14997008442878723, -0.18971434235572815, -0.1178363487124443, 0.14658032357692719, 0.2887987494468689, -0.311062216758728, 0.013476553373038769, -0.019368484616279602, 0.17613445222377777, -0.3448125123977661, -0.1364353895187378, 0.07437089085578918, -0.005232963245362043, -0.17424525320529938, 0.0005958561087027192, 0.011437807232141495, -0.3326968848705292, 0.15036839246749878, 0.27264437079429626, -0.06121019273996353, -0.11970936506986618, -0.21436360478401184, 1.2016054391860962, 0.25149083137512207, 0.540777862071991, 0.0015413237269967794, -0.47897058725357056, 0.6974573731422424, -0.5686131715774536, 0.8093838095664978, 1.7492735385894775, -0.08586230874061584, -1.1748616695404053, -0.0019973507151007652, -0.10483703017234802, 1.1019824743270874, 0.00916005577892065, -0.05810127034783363, -0.08483171463012695, -0.33433252573013306, 0.47186142206192017, -0.03784961998462677, -0.10008599609136581, -0.06760873645544052, 0.11731500178575516, 2.083373546600342, 0.36512690782546997, 0.12359095364809036, -0.17322567105293274, -0.5954174399375916, -0.664002001285553, -0.7559688687324524, 0.2585269510746002, 0.09203799068927765, -0.34636759757995605, 0.15286214649677277, 0.03661971911787987, 0.5951442122459412, 0.004546092823147774, -0.03838701173663139, -0.5216450691223145, -0.15255127847194672, 0.6591381430625916, -0.42587870359420776, -0.013055965304374695, 0.26791542768478394, -0.42988717555999756, 0.06328100711107254, 0.8119242787361145, 0.11873671412467957, -0.6298862099647522, 0.5956037044525146, -0.7082923054695129, -0.8452447652816772, 0.23914732038974762, 0.21034133434295654, -0.717399001121521, 0.2983108162879944, 0.6209869980812073, -0.140838623046875, -0.4220437705516815, -0.8811973929405212, 0.40350261330604553, 0.23589693009853363, 0.3691011071205139, 0.6700326204299927, -0.39092186093330383, -0.6132438778877258, -0.026762746274471283, 0.8621531128883362, 1.1332632303237915, -0.041316304355859756, 0.02003556117415428, 0.634650468826294, -1.5741407871246338, -0.8863347768783569, -0.8439550399780273, -1.366637110710144, 0.06646597385406494, -0.3964800238609314, -0.41438424587249756, 0.6846640706062317, -0.7748998999595642, -0.8067624568939209, -0.030613016337156296, -0.16540996730327606, 0.3083365559577942, -0.37768617272377014, 0.08395405858755112, 0.33615842461586, -0.005124587099999189, 1.3858871459960938, -0.41624024510383606, -0.06792216747999191, 0.2983757257461548, 0.21231384575366974, 0.6543921232223511, -1.843520998954773, 0.351342111825943, -1.013131022453308, -0.03491658717393875, 0.2746826410293579, -0.6124066710472107, -0.21598121523857117, 0.07827732712030411, -0.18868006765842438, 0.11325693130493164, -1.6732641458511353, -1.0742149353027344, 0.15047533810138702, -0.2706822454929352, 0.6182756423950195, -0.5376579761505127, 0.4419536888599396, 0.9979775547981262, -8.01710702944547e-05, -0.34362760186195374, 1.2654173374176025, -0.16981007158756256, -0.48054733872413635, 0.6912459135055542, -0.6626031994819641, -0.08096565306186676, 0.18935739994049072, -1.8396344184875488, -0.6384330987930298, -0.6475745439529419, -0.8829994201660156, 0.5036293864250183, 0.2629949152469635, -0.6192744374275208, 0.13119137287139893, 0.06775165349245071, -0.13195064663887024, -0.5711817741394043, 0.3065890669822693, -0.4124002158641815, 0.46052229404449463, 0.16278278827667236, 0.36992064118385315, -1.4331969022750854, -0.2478119283914566, 0.6254206895828247, -1.2886425256729126, -0.22830262780189514, 0.1981838345527649, 0.3197638988494873, -0.09843017160892487, -0.2952016294002533, -0.6947237849235535, 0.34806567430496216, -0.3122442662715912, -0.6666228771209717, 0.6453564763069153, -0.10350070893764496, -0.03413950651884079, -0.5424526333808899, 0.7820578217506409, 1.2924869060516357, 0.09157612174749374, 0.09557986259460449, -0.12149297446012497, -0.6464858651161194, -1.0642224550247192, -0.03382648155093193, 0.25556135177612305, -0.6870264410972595, 0.2877782881259918, 0.06554123014211655, -0.42244812846183777, -0.3739263415336609, -0.35396358370780945, 0.28208133578300476, -0.04505963996052742, 0.22228331863880157, -0.2973048686981201, -0.2971132695674896, -0.20536284148693085, -0.2616841197013855, -0.8480697870254517, 0.07906690984964371, 0.2881016433238983, -0.29105180501937866, 1.0354727506637573, 1.0971664190292358, 0.8235355615615845, -0.37308675050735474, -0.6394267678260803, -0.9406262040138245, -0.3414047956466675, -0.026550495997071266, 0.011970732361078262, -0.40209099650382996, -0.36487412452697754, 0.08537843823432922, 0.24994392693042755, 0.7774080634117126, -0.5960047245025635, -0.1767701953649521, -0.23424425721168518, -0.46658986806869507, 0.40000084042549133, 0.8696478009223938, 0.03904033824801445, 0.06901958584785461, -0.13913920521736145, 0.5866820812225342, -0.4087997376918793, 0.5375671982765198, 0.07793786376714706, -1.064713716506958, 0.012222635559737682, 0.10384431481361389, 0.008097008801996708, 0.13362936675548553, 0.7467359304428101, 0.16099190711975098, 0.23579207062721252, -0.28179216384887695, -0.14189283549785614, 0.49247393012046814, 0.20043537020683289, 0.14281590282917023, -0.5077271461486816, -0.35479646921157837, -0.39307811856269836, -0.7931295037269592, 0.11573491990566254, 0.02514616772532463, -0.023222792893648148, 0.15203650295734406, 0.6167893409729004, -0.2087707817554474, -0.26956886053085327, 0.422235369682312, -0.036826908588409424, -0.4588862955570221, 0.03270633891224861, -0.10106940567493439, 0.4298739731311798, -0.6018723249435425, 0.2724285125732422, -0.525924563407898, -0.5065925717353821, -0.10070765018463135, 0.7382825613021851, -0.031159061938524246, -0.4402030408382416, 0.9572052359580994, -0.6551192402839661, 0.12259186059236526, -0.4671074151992798, -0.21867205202579498, 0.10852788388729095, 0.2100231945514679, -0.12940935790538788, 0.207979217171669, -0.15334691107273102, 0.15364672243595123, 0.49508118629455566, 0.011411430314183235, 0.09823483228683472, -0.054107051342725754, 0.008963619358837605, 0.12270919233560562, 0.23244401812553406, 0.18004395067691803, -0.06648212671279907, 0.02520591765642166, 0.4420541226863861, -0.08115142583847046, 0.07090878486633301, -0.2630368769168854, -0.5921692252159119, 0.2861429452896118, 0.09047992527484894, -0.2831847667694092, -0.45392900705337524, 0.3405632972717285, -0.21615129709243774, 0.019999999552965164], "sample_rate": 48000}}]}, "weights": [], "sample_rate": 48000} \ No newline at end of file +{"version": "0.7.0", "architecture": "SlimmableContainer", "config": {"submodels": [{"max_value": 0.33, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 44, "second": 41}, "loudness": -37.8406867980957, "gain": 0.13508800804658277, "name": "Test LSTM", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": null}}, "architecture": "LSTM", "config": {"input_size": 1, "hidden_size": 3, "num_layers": 1}, "weights": [-0.21677088737487793, -0.6683622002601624, -0.2560940980911255, -0.3588429093360901, 0.17952610552310944, 0.19445613026618958, -0.01662646047770977, 0.5353694558143616, -0.2536540627479553, -0.5132213234901428, -0.020476307719945908, 0.08592455089092255, -0.6891753673553467, 0.3627359867095947, 0.008421811275184155, 0.3113192617893219, 0.14251480996608734, 0.07989779114723206, -0.18211324512958527, 0.7118963003158569, 0.41084015369415283, -0.6571938395500183, -0.13214066624641418, -0.2698603868484497, 0.49387243390083313, -0.3491725027561188, 0.6353667974472046, -0.5005152225494385, 0.2052856683731079, -0.4301638901233673, -0.15770092606544495, -0.7181791067123413, 0.056290093809366226, -0.49049463868141174, 0.6623441576957703, 0.09029324352741241, 0.34005245566368103, 0.16416560113430023, 0.15520110726356506, -0.4155678153038025, -0.36928507685661316, 0.3211132884025574, -0.6769840121269226, -0.1575538069009781, 0.05268515646457672, -0.4191459119319916, 0.599330484867096, 0.21518059074878693, -4.246325492858887, -3.315647840499878, -4.328850746154785, 4.496089458465576, 5.015639305114746, 3.6492037773132324, 0.14431169629096985, -0.6633821725845337, 0.11673200130462646, -0.1418764889240265, -0.4897872805595398, -0.8689419031143188, -0.06714004278182983, -0.4450395107269287, -0.02142983116209507, -0.15136894583702087, -2.775207996368408, -0.08681213855743408, 0.05702732503414154, 0.670292317867279, 0.31442636251449585, 0.30793967843055725], "sample_rate": 48000}}, {"max_value": 0.66, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 32, "second": 27}, "loudness": -20.020729064941406, "gain": 0.19575619747898518, "name": "Test Model", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.13345033695550146}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 3, "kernel_size": 3, "dilations": [1, 2], "activation": "Tanh", "gated": false, "head_bias": false}, {"input_size": 3, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [8], "activation": "Tanh", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.6180188059806824, 1.0314024686813354, -1.0111560821533203, -0.38462021946907043, 0.35968291759490967, 0.5255971550941467, 0.19149275124073029, -0.18075695633888245, -0.33711034059524536, -0.21037575602531433, 0.2007753700017929, 0.21644853055477142, -1.3216396570205688, -0.35082393884658813, 0.43541353940963745, 0.9693092107772827, 0.2394428700208664, -0.41078877449035645, -1.193748116493225, -0.14876757562160492, 0.8413559198379517, 0.24491633474826813, 0.8857091665267944, 0.5647665858268738, 0.08301573246717453, -0.801490843296051, 0.168976828455925, -0.5413634181022644, 0.484220415353775, 0.021656272932887077, -0.15155009925365448, 0.07081033289432526, 0.00019397131109144539, -0.7408013939857483, -1.3308452367782593, -1.0403972864151, 0.016809873282909393, 0.6778652667999268, 0.28265541791915894, -0.28287461400032043, 1.0525944232940674, -0.6385797262191772, -0.2195468544960022, -0.3150196671485901, -0.8814508318901062, -0.2746180295944214, 0.15367186069488525, 0.22431065142154694, -0.056788790971040726, -0.38902369141578674, 0.5406259894371033, 0.3566059470176697, 0.14383991062641144, -0.25409433245658875, 0.16139137744903564, -0.05857989564538002, -0.18448838591575623, -0.253485769033432, -0.42405444383621216, -0.030114537104964256, 0.47283637523651123, 0.14930365979671478, -0.4410354793071747, -0.21976807713508606, -0.12736600637435913, -0.5674286484718323, -0.347588449716568, -0.3687525689601898, 0.4130803942680359, 0.8551775217056274, -0.05746064335107803, -0.38243237137794495, 0.20036561787128448, 0.25542038679122925, -0.0819990262389183, 0.19469600915908813, 0.10215214639902115, -0.26087674498558044, -0.1773151010274887, -0.09658292680978775, -0.7381710410118103, 0.7003506422042847, 0.7253592014312744, -0.07488955557346344, -0.23439547419548035, -0.5138604044914246, -0.7976311445236206, -0.8090851902961731, -0.37562188506126404, -1.163352131843567, 0.30907657742500305, 0.0564480796456337, 0.1190297082066536, 0.2310808300971985, -0.45360898971557617, -0.11524498462677002, 0.2552330493927002, 0.2913571298122406, -0.23171702027320862, -0.35578709840774536, 0.40732908248901367, 0.7458747029304504, 0.27514976263046265, -0.7503036856651306, -0.6707972884178162, -0.4248569905757904, -0.1671624332666397, -0.14162226021289825, 0.37550851702690125, -0.038120146840810776, 0.16232982277870178, -0.05173371359705925, -0.2842361629009247, 0.38820165395736694, 0.521754801273346, -0.3581869900226593, 0.21531476080417633, 0.11342520266771317, 0.01764630153775215, 0.07780527323484421, 0.9356631636619568, 0.04235581308603287, -0.3450177311897278, 0.3345951437950134, -0.678291380405426, -0.4191069006919861, -0.1770099401473999, -5.386871337890625, -5.130850791931152, -0.4049331247806549, 0.019999999552965164], "sample_rate": 48000}}, {"max_value": 1.0, "model": {"version": "0.5.4", "metadata": {"date": {"year": 2026, "month": 1, "day": 18, "hour": 19, "minute": 28, "second": 2}, "loudness": -25.50621795654297, "gain": 0.8174147104354939, "name": "Atrisan 100 HT Pedal Jump Chan Voice 4 Blend 50 - Nuvo N22", "modeled_by": "tone3000", "gear_type": "amp", "gear_make": "tz-make", "gear_model": "tz-model", "tone_type": "overdrive", "input_level_dbu": 8.25, "output_level_dbu": 4, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [335], "safety_factor": 1, "recommended": 334, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.05744442289189271}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 4, "kernel_size": 3, "dilations": [1, 2, 4, 8, 16, 32, 64], "activation": "ReLU", "gated": false, "head_bias": false}, {"input_size": 4, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512], "activation": "ReLU", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.43676555156707764, 0.18804845213890076, -1.191544771194458, -1.2514153718948364, 0.1522054672241211, 0.2674163281917572, 0.11941885948181152, -0.016747985035181046, -0.24142038822174072, -0.08158593624830246, 0.1658506542444229, 0.12450455874204636, -0.1257639080286026, 0.05097454413771629, 0.06655367463827133, 0.15613363683223724, 0.3628908693790436, 0.16920273005962372, -0.4865663945674896, -0.33004868030548096, 0.1686093509197235, 0.4942941963672638, 0.14733701944351196, 0.1264810413122177, -0.3330173194408417, 0.2558712959289551, 0.1980869621038437, -0.5377613306045532, -0.44927188754081726, -0.10965251177549362, -0.2049286812543869, 0.5187842845916748, -0.11666373908519745, -0.010038944892585278, -0.4929092228412628, -0.3522462546825409, -0.30443158745765686, -0.05553298071026802, 0.032637786120176315, -0.01095358282327652, -0.2228831946849823, -0.07661055028438568, 0.18166741728782654, -0.02288321778178215, -0.2550153434276581, -0.27006709575653076, -0.05640152841806412, 0.2399696558713913, 0.01374511606991291, -0.2519863247871399, 0.25369852781295776, 0.43098628520965576, 0.24656431376934052, 0.05089268833398819, 0.2244647890329361, -0.3239988088607788, 0.026821687817573547, -0.5183702707290649, -0.549621045589447, -0.6563447117805481, -0.17373943328857422, -0.32807308435440063, 0.2662317454814911, -0.5284045934677124, 0.4098321795463562, -0.1177985891699791, -0.3497377634048462, 0.06472523510456085, 0.2881721258163452, 0.4962410628795624, -0.4693456292152405, 0.22105255722999573, 0.5390405058860779, 0.6857721209526062, 0.13449627161026, -0.22106148302555084, -0.015273668803274632, -0.15233269333839417, 0.0054369233548641205, -0.2990502715110779, -0.6390000581741333, 0.09520208835601807, 0.5206401348114014, -0.30539414286613464, 0.005384453106671572, -0.11123053729534149, -0.3819287419319153, -0.2212216705083847, 0.4531766176223755, -0.6183855533599854, -0.07028502225875854, 0.5584202408790588, 0.03141379728913307, 0.03053859807550907, 0.08987420797348022, 0.10635538399219513, -0.004241787828505039, -0.2514967918395996, 0.4621999263763428, -0.24512320756912231, 0.020135050639510155, 0.42594560980796814, -0.3939764201641083, -0.4036279320716858, -0.6264017820358276, 0.12763042747974396, -0.11675230413675308, -0.3192313015460968, -0.0003565576334949583, -0.06628905236721039, -0.3489648103713989, -0.18046769499778748, -0.042343053966760635, 0.20209242403507233, -0.044064972549676895, 0.010927309282124043, -0.4592772126197815, -0.2547818720340729, 0.4999264180660248, -0.04825885593891144, 0.2511541247367859, -0.05963046848773956, -0.4923741817474365, -0.19782790541648865, 0.18921701610088348, -0.143302783370018, -0.417974591255188, 0.4820250868797302, -0.01435916032642126, -0.09722636640071869, 0.04334542900323868, 0.20531202852725983, -0.6767648458480835, -0.03919640928506851, 0.41943681240081787, -0.705767810344696, 1.0928969383239746, 0.008152804337441921, 0.30072590708732605, 0.700724720954895, 1.4694486856460571, -0.36657166481018066, 0.29822444915771484, 0.08182942867279053, -1.1029194593429565, 0.39373770356178284, 0.572385847568512, -0.10765771567821503, 0.6150015592575073, 0.7301293611526489, -0.8640158772468567, -0.6661192178726196, -0.17441526055335999, 0.23340773582458496, 0.2347957193851471, -0.5018205642700195, 0.04749491065740585, -0.25646737217903137, -0.12705065310001373, -0.2656175196170807, -0.14754967391490936, -0.16251829266548157, -0.26762738823890686, -0.2506292164325714, -0.023960385471582413, 0.08543525636196136, -0.051170505583286285, 0.24774709343910217, -0.29134371876716614, 0.25539499521255493, 0.19203688204288483, -0.09644774347543716, 0.045086562633514404, 0.2614458203315735, -0.14013680815696716, 0.5095819234848022, 0.1808817982673645, 0.13184405863285065, 0.2857828140258789, -0.2877650856971741, 0.025841550901532173, -0.10298394411802292, 0.4531080424785614, 0.19967995584011078, -0.0035516824573278427, 0.6057309508323669, -0.01614478975534439, -0.024831678718328476, -0.23062309622764587, 0.0057058511301875114, -0.22100116312503815, 0.6274505257606506, -0.09544087946414948, -0.47833094000816345, -0.07983476668596268, -0.32524535059928894, -0.9022202491760254, 0.17296163737773895, 0.1715262085199356, 0.44342607259750366, 0.0672280341386795, 0.3143714964389801, -0.16193732619285583, -0.5337017774581909, -0.23426392674446106, 0.31633561849594116, 0.16039276123046875, 0.3396058678627014, 0.1790986955165863, 0.22826147079467773, 0.565819501876831, -0.18677009642124176, 0.11501625180244446, -0.9280168414115906, -0.5102543234825134, 0.4280734062194824, -0.4131118953227997, -0.3216524124145508, -0.9526995420455933, -0.8283767700195312, -0.02265196479856968, 0.3181364834308624, -0.13400879502296448, -0.3635147213935852, -0.07217840850353241, 0.5390769839286804, 0.022873638197779655, 0.15108828246593475, 0.06688182055950165, -0.06298623979091644, -0.04183664545416832, 0.26526492834091187, -0.20283886790275574, 0.8089739084243774, 0.39357757568359375, -0.4892053008079529, -0.4210922122001648, 0.0030071621295064688, 0.1889152228832245, -0.3113728165626526, 0.04760019853711128, 0.5401822924613953, -0.31828656792640686, -0.022103704512119293, -0.7838840484619141, 0.23758691549301147, 0.6584234237670898, -0.14207355678081512, 0.3508256673812866, 0.24494409561157227, 0.37631094455718994, -0.036634355783462524, 1.0158957242965698, -0.4377710223197937, -0.2699510157108307, 0.011075957678258419, -0.9512584209442139, 1.0744872093200684, 0.07266976684331894, -0.5702192783355713, -0.22477132081985474, 0.10158557444810867, 0.5408655405044556, -0.05424047261476517, -0.22979958355426788, 0.12589116394519806, -0.3061460554599762, -0.007357880473136902, 0.160592719912529, -0.8183864951133728, -0.1873759627342224, 0.4029034972190857, 0.20340028405189514, -0.19033348560333252, -0.6387582421302795, 0.3744193911552429, 0.4734930992126465, -0.7402716279029846, 0.16290104389190674, 0.231669083237648, 0.22414864599704742, 0.003755988087505102, -0.0671466663479805, 0.1964668184518814, 0.014198299497365952, 0.163277730345726, -0.26071494817733765, 0.35350218415260315, -0.686671793460846, 0.459243506193161, -0.09164588153362274, 0.7604275345802307, 0.4730943739414215, 0.35176384449005127, 0.44463688135147095, 0.035675011575222015, 0.2871439754962921, -0.21191704273223877, 0.8446514010429382, -0.881138026714325, -0.5140098929405212, -0.2590724527835846, -0.6394899487495422, 1.0582557916641235, 0.19049172103405, -0.007477824576199055, -0.0690576359629631, 0.10438528656959534, 0.46519139409065247, 0.2671721279621124, -0.8850185871124268, -0.07695616781711578, 0.06778068840503693, 0.09831968694925308, 0.425837904214859, 0.21560505032539368, -0.0973641574382782, 0.11831096559762955, 0.2720680832862854, -0.8112271428108215, 0.0679216980934143, 0.0034201480448246002, -1.1940691471099854, 0.015147575177252293, 0.2989473044872284, 0.4385072588920593, 0.22488915920257568, -0.07610563188791275, 0.24487024545669556, 0.16010652482509613, -0.1590120494365692, -0.8069810271263123, 0.3454744517803192, 0.10192205011844635, -0.5487010478973389, 0.08557324856519699, -0.0033477218821644783, -0.40646129846572876, -0.3718165159225464, 0.07761954516172409, -0.1472809761762619, -0.39236438274383545, -0.04602040350437164, -0.2916988134384155, -0.35268932580947876, 0.44220033288002014, 1.061747431755066, 0.01184292882680893, 0.029237236827611923, -0.3696916997432709, -0.3326391875743866, 0.3186306059360504, -0.0686657726764679, -0.12802480161190033, 0.059870608150959015, 0.4420037567615509, -0.11589302867650986, 0.10948559641838074, 0.3228295147418976, 0.30819857120513916, -0.5482281446456909, -1.5860124826431274, -1.1525928974151611, 0.501322865486145, 0.24488481879234314, 0.3214830756187439, 0.46026182174682617, -1.3560254573822021, -0.6456385850906372, -0.7880288362503052, 0.8956019878387451, 0.41244542598724365, -0.6440726518630981, -0.7221627235412598, -0.25085917115211487, -0.7078524231910706, 0.4188958704471588, 0.45524659752845764, 0.3029322028160095, -0.22305667400360107, 0.44652125239372253, 0.24373604357242584, 0.3368196487426758, 0.1511261910200119, 0.2610892951488495, -0.012466066516935825, 0.519991397857666, 0.3664250671863556, 0.04987747222185135, -0.04385135695338249, -0.2866438329219818, -0.016423135995864868, -0.6226651668548584, -0.07403579354286194, -0.25110307335853577, 0.13762260973453522, 0.3649454116821289, -0.04414776712656021, -0.02799362502992153, 0.39993947744369507, -0.059658318758010864, -0.5658756494522095, -0.38595327734947205, 0.12831152975559235, -0.6940039396286011, -0.21010565757751465, 0.0833023339509964, 0.2953319549560547, -0.2192569226026535, -9.963240881916136e-05, -0.4918636083602905, -0.35004717111587524, -0.11263000965118408, 0.5789287090301514, 0.333292156457901, 0.03616069629788399, -0.723102331161499, 0.07424107939004898, 0.27536284923553467, -0.3164575397968292, 0.4204881191253662, -0.10002204775810242, 0.045674219727516174, 0.4877814054489136, -0.13877654075622559, -0.9487224817276001, -0.5420687794685364, 0.15843534469604492, -0.8356834053993225, -0.3401522934436798, -0.021845858544111252, 0.24137890338897705, 0.6131256222724915, -0.5279566645622253, 0.4040375053882599, -0.287713885307312, -0.32596370577812195, -0.289026141166687, -0.8558264970779419, -0.8393163681030273, -0.6748902797698975, -1.5344449281692505, -0.48501765727996826, 0.7561529278755188, -0.5639386773109436, 0.2747798264026642, 0.31883418560028076, 0.46465715765953064, 0.8148818016052246, -1.0762479305267334, 0.5226246118545532, 0.8592436909675598, 0.05685063451528549, -1.098716378211975, 1.0224401950836182, 1.6439732313156128, 0.15941590070724487, 0.33981525897979736, -0.736503005027771, -0.1396108865737915, -0.3593847453594208, 0.18113897740840912, 0.3901767134666443, 0.24246807396411896, -0.3559393584728241, 0.3014945983886719, 0.5807337760925293, 0.632666289806366, -0.3279235064983368, -0.3521895110607147, 0.21897214651107788, 0.2008153200149536, 0.18349437415599823, 0.2843616306781769, -0.07296476513147354, 0.0050212121568620205, 0.1398988664150238, -0.04363537207245827, -0.10488884150981903, 0.018994251266121864, -0.8944122195243835, -0.1002153530716896, -0.12303996831178665, -0.6947574019432068, -0.20797944068908691, -0.25055378675460815, 0.8080053925514221, -0.1779334545135498, -0.21596449613571167, -0.5812117457389832, 0.07938572019338608, 0.31331679224967957, 1.3328310251235962, -0.1157936379313469, -0.20552347600460052, 0.2777186930179596, -0.4894363582134247, 0.1485048085451126, 0.2016707956790924, 0.12642067670822144, -0.6121338605880737, 0.07307889312505722, 0.5374605655670166, 0.6080096960067749, -0.7628602981567383, -0.4795125722885132, 0.14357036352157593, 0.03981512784957886, -0.47786933183670044, 0.548004150390625, -0.4770188629627228, -0.007587160915136337, 0.4921312630176544, -1.8222495317459106, 0.8633298873901367, -0.24518749117851257, -1.1610788106918335, -0.7625094652175903, 0.562911331653595, 0.8363901376724243, -0.5850722789764404, 0.18943746387958527, -0.19145213067531586, 0.5438283085823059, 0.27744850516319275, -0.8637493848800659, 1.191653847694397, -0.6768492460250854, -0.30685824155807495, -1.0220935344696045, 1.1770503520965576, 1.064857840538025, -0.09791866689920425, -0.49691858887672424, -0.18965063989162445, 0.18372981250286102, -0.180926114320755, -0.11052561551332474, -0.14311599731445312, -0.0899554044008255, -0.23982501029968262, -0.14997008442878723, -0.18971434235572815, -0.1178363487124443, 0.14658032357692719, 0.2887987494468689, -0.311062216758728, 0.013476553373038769, -0.019368484616279602, 0.17613445222377777, -0.3448125123977661, -0.1364353895187378, 0.07437089085578918, -0.005232963245362043, -0.17424525320529938, 0.0005958561087027192, 0.011437807232141495, -0.3326968848705292, 0.15036839246749878, 0.27264437079429626, -0.06121019273996353, -0.11970936506986618, -0.21436360478401184, 1.2016054391860962, 0.25149083137512207, 0.540777862071991, 0.0015413237269967794, -0.47897058725357056, 0.6974573731422424, -0.5686131715774536, 0.8093838095664978, 1.7492735385894775, -0.08586230874061584, -1.1748616695404053, -0.0019973507151007652, -0.10483703017234802, 1.1019824743270874, 0.00916005577892065, -0.05810127034783363, -0.08483171463012695, -0.33433252573013306, 0.47186142206192017, -0.03784961998462677, -0.10008599609136581, -0.06760873645544052, 0.11731500178575516, 2.083373546600342, 0.36512690782546997, 0.12359095364809036, -0.17322567105293274, -0.5954174399375916, -0.664002001285553, -0.7559688687324524, 0.2585269510746002, 0.09203799068927765, -0.34636759757995605, 0.15286214649677277, 0.03661971911787987, 0.5951442122459412, 0.004546092823147774, -0.03838701173663139, -0.5216450691223145, -0.15255127847194672, 0.6591381430625916, -0.42587870359420776, -0.013055965304374695, 0.26791542768478394, -0.42988717555999756, 0.06328100711107254, 0.8119242787361145, 0.11873671412467957, -0.6298862099647522, 0.5956037044525146, -0.7082923054695129, -0.8452447652816772, 0.23914732038974762, 0.21034133434295654, -0.717399001121521, 0.2983108162879944, 0.6209869980812073, -0.140838623046875, -0.4220437705516815, -0.8811973929405212, 0.40350261330604553, 0.23589693009853363, 0.3691011071205139, 0.6700326204299927, -0.39092186093330383, -0.6132438778877258, -0.026762746274471283, 0.8621531128883362, 1.1332632303237915, -0.041316304355859756, 0.02003556117415428, 0.634650468826294, -1.5741407871246338, -0.8863347768783569, -0.8439550399780273, -1.366637110710144, 0.06646597385406494, -0.3964800238609314, -0.41438424587249756, 0.6846640706062317, -0.7748998999595642, -0.8067624568939209, -0.030613016337156296, -0.16540996730327606, 0.3083365559577942, -0.37768617272377014, 0.08395405858755112, 0.33615842461586, -0.005124587099999189, 1.3858871459960938, -0.41624024510383606, -0.06792216747999191, 0.2983757257461548, 0.21231384575366974, 0.6543921232223511, -1.843520998954773, 0.351342111825943, -1.013131022453308, -0.03491658717393875, 0.2746826410293579, -0.6124066710472107, -0.21598121523857117, 0.07827732712030411, -0.18868006765842438, 0.11325693130493164, -1.6732641458511353, -1.0742149353027344, 0.15047533810138702, -0.2706822454929352, 0.6182756423950195, -0.5376579761505127, 0.4419536888599396, 0.9979775547981262, -8.01710702944547e-05, -0.34362760186195374, 1.2654173374176025, -0.16981007158756256, -0.48054733872413635, 0.6912459135055542, -0.6626031994819641, -0.08096565306186676, 0.18935739994049072, -1.8396344184875488, -0.6384330987930298, -0.6475745439529419, -0.8829994201660156, 0.5036293864250183, 0.2629949152469635, -0.6192744374275208, 0.13119137287139893, 0.06775165349245071, -0.13195064663887024, -0.5711817741394043, 0.3065890669822693, -0.4124002158641815, 0.46052229404449463, 0.16278278827667236, 0.36992064118385315, -1.4331969022750854, -0.2478119283914566, 0.6254206895828247, -1.2886425256729126, -0.22830262780189514, 0.1981838345527649, 0.3197638988494873, -0.09843017160892487, -0.2952016294002533, -0.6947237849235535, 0.34806567430496216, -0.3122442662715912, -0.6666228771209717, 0.6453564763069153, -0.10350070893764496, -0.03413950651884079, -0.5424526333808899, 0.7820578217506409, 1.2924869060516357, 0.09157612174749374, 0.09557986259460449, -0.12149297446012497, -0.6464858651161194, -1.0642224550247192, -0.03382648155093193, 0.25556135177612305, -0.6870264410972595, 0.2877782881259918, 0.06554123014211655, -0.42244812846183777, -0.3739263415336609, -0.35396358370780945, 0.28208133578300476, -0.04505963996052742, 0.22228331863880157, -0.2973048686981201, -0.2971132695674896, -0.20536284148693085, -0.2616841197013855, -0.8480697870254517, 0.07906690984964371, 0.2881016433238983, -0.29105180501937866, 1.0354727506637573, 1.0971664190292358, 0.8235355615615845, -0.37308675050735474, -0.6394267678260803, -0.9406262040138245, -0.3414047956466675, -0.026550495997071266, 0.011970732361078262, -0.40209099650382996, -0.36487412452697754, 0.08537843823432922, 0.24994392693042755, 0.7774080634117126, -0.5960047245025635, -0.1767701953649521, -0.23424425721168518, -0.46658986806869507, 0.40000084042549133, 0.8696478009223938, 0.03904033824801445, 0.06901958584785461, -0.13913920521736145, 0.5866820812225342, -0.4087997376918793, 0.5375671982765198, 0.07793786376714706, -1.064713716506958, 0.012222635559737682, 0.10384431481361389, 0.008097008801996708, 0.13362936675548553, 0.7467359304428101, 0.16099190711975098, 0.23579207062721252, -0.28179216384887695, -0.14189283549785614, 0.49247393012046814, 0.20043537020683289, 0.14281590282917023, -0.5077271461486816, -0.35479646921157837, -0.39307811856269836, -0.7931295037269592, 0.11573491990566254, 0.02514616772532463, -0.023222792893648148, 0.15203650295734406, 0.6167893409729004, -0.2087707817554474, -0.26956886053085327, 0.422235369682312, -0.036826908588409424, -0.4588862955570221, 0.03270633891224861, -0.10106940567493439, 0.4298739731311798, -0.6018723249435425, 0.2724285125732422, -0.525924563407898, -0.5065925717353821, -0.10070765018463135, 0.7382825613021851, -0.031159061938524246, -0.4402030408382416, 0.9572052359580994, -0.6551192402839661, 0.12259186059236526, -0.4671074151992798, -0.21867205202579498, 0.10852788388729095, 0.2100231945514679, -0.12940935790538788, 0.207979217171669, -0.15334691107273102, 0.15364672243595123, 0.49508118629455566, 0.011411430314183235, 0.09823483228683472, -0.054107051342725754, 0.008963619358837605, 0.12270919233560562, 0.23244401812553406, 0.18004395067691803, -0.06648212671279907, 0.02520591765642166, 0.4420541226863861, -0.08115142583847046, 0.07090878486633301, -0.2630368769168854, -0.5921692252159119, 0.2861429452896118, 0.09047992527484894, -0.2831847667694092, -0.45392900705337524, 0.3405632972717285, -0.21615129709243774, 0.019999999552965164], "sample_rate": 48000}}]}, "weights": [], "sample_rate": 48000} \ No newline at end of file diff --git a/tools/render.cpp b/tools/render.cpp index 8d491136..c3cabb2a 100644 --- a/tools/render.cpp +++ b/tools/render.cpp @@ -9,9 +9,9 @@ #include #include -#include "NAM/container.h" #include "NAM/dsp.h" #include "NAM/get_dsp.h" +#include "NAM/slimmable.h" #include "wav.h" namespace @@ -116,14 +116,14 @@ int main(int argc, char* argv[]) if (hasSlim) { - auto* container = dynamic_cast(model.get()); - if (!container) + auto* slimmable = dynamic_cast(model.get()); + if (!slimmable) { - std::cerr << "Error: --slim requires a model that implements the Slimmable interface (e.g. SlimmableContainer)\n"; + std::cerr << "Error: --slim requires a model that implements the SlimmableModel interface\n"; return 1; } std::cerr << "Setting slimmable size to " << slimValue << "\n"; - model->SetSlimmableSize(slimValue); + slimmable->SetSlimmableSize(slimValue); } std::vector inputAudio; diff --git a/tools/test/test_container.cpp b/tools/test/test_container.cpp index 50ddc386..9030e28a 100644 --- a/tools/test/test_container.cpp +++ b/tools/test/test_container.cpp @@ -11,6 +11,7 @@ #include "NAM/container.h" #include "NAM/get_dsp.h" +#include "NAM/slimmable.h" namespace test_container { @@ -35,7 +36,7 @@ nlohmann::json build_container_json(const std::string& small_path, const std::st nlohmann::json large_model = load_nam_json(large_path); nlohmann::json container; - container["version"] = "0.6.1"; + container["version"] = "0.7.0"; container["architecture"] = "SlimmableContainer"; container["config"]["submodels"] = nlohmann::json::array( {{{"max_value", 0.33}, {"model", small_model}}, {{"max_value", 0.66}, {"model", medium_model}}, {{"max_value", 1.0}, {"model", large_model}}}); @@ -99,13 +100,16 @@ void test_container_slimmable_selects_submodel() NAM_SAMPLE* in_ptr = input.data(); NAM_SAMPLE* out_ptr; + auto* slimmable = dynamic_cast(dsp.get()); + assert(slimmable != nullptr); + // Process at minimum size (selects first submodel) - dsp->SetSlimmableSize(0.0); + slimmable->SetSlimmableSize(0.0); out_ptr = out_small.data(); dsp->process(&in_ptr, &out_ptr, buffer_size); // Process at maximum size (selects last submodel) - dsp->SetSlimmableSize(1.0); + slimmable->SetSlimmableSize(1.0); out_ptr = out_large.data(); dsp->process(&in_ptr, &out_ptr, buffer_size); @@ -136,23 +140,31 @@ void test_container_boundary_values() NAM_SAMPLE* in_ptr = input.data(); NAM_SAMPLE* out_ptr = output.data(); - // Test exact boundary values - dsp->SetSlimmableSize(0.33); // Should select first submodel (max_value=0.33) + auto* slimmable = dynamic_cast(dsp.get()); + assert(slimmable != nullptr); + + // Test exact boundary values (max_value is exclusive: val < max_value selects that submodel) + slimmable->SetSlimmableSize(0.32); // Should select first submodel (0.32 < 0.33) + dsp->process(&in_ptr, &out_ptr, buffer_size); + for (int i = 0; i < buffer_size; i++) + assert(std::isfinite(output[i])); + + slimmable->SetSlimmableSize(0.33); // Should select second submodel (0.33 is NOT < 0.33, but IS < 0.66) dsp->process(&in_ptr, &out_ptr, buffer_size); for (int i = 0; i < buffer_size; i++) assert(std::isfinite(output[i])); - dsp->SetSlimmableSize(0.34); // Should select second submodel (max_value=0.66) + slimmable->SetSlimmableSize(0.65); // Should select second submodel (0.65 < 0.66) dsp->process(&in_ptr, &out_ptr, buffer_size); for (int i = 0; i < buffer_size; i++) assert(std::isfinite(output[i])); - dsp->SetSlimmableSize(0.66); // Should select second submodel (max_value=0.66) + slimmable->SetSlimmableSize(0.66); // Should select third/last submodel (0.66 is NOT < 0.66, fallback) dsp->process(&in_ptr, &out_ptr, buffer_size); for (int i = 0; i < buffer_size; i++) assert(std::isfinite(output[i])); - dsp->SetSlimmableSize(1.0); // Should select third submodel (max_value=1.0) + slimmable->SetSlimmableSize(1.0); // Should select third/last submodel (fallback) dsp->process(&in_ptr, &out_ptr, buffer_size); for (int i = 0; i < buffer_size; i++) assert(std::isfinite(output[i])); @@ -161,7 +173,7 @@ void test_container_boundary_values() void test_container_empty_submodels_throws() { nlohmann::json j; - j["version"] = "0.6.1"; + j["version"] = "0.7.0"; j["architecture"] = "SlimmableContainer"; j["config"]["submodels"] = nlohmann::json::array(); j["weights"] = nlohmann::json::array(); @@ -185,7 +197,7 @@ void test_container_last_max_value_must_cover_one() auto small_json = load_nam_json("example_models/lstm.nam"); nlohmann::json j; - j["version"] = "0.6.1"; + j["version"] = "0.7.0"; j["architecture"] = "SlimmableContainer"; j["config"]["submodels"] = nlohmann::json::array({{{"max_value", 0.5}, {"model", small_json}}}); j["weights"] = nlohmann::json::array(); @@ -216,7 +228,7 @@ void test_container_unsorted_submodels_throws() auto medium_json = load_nam_json("example_models/wavenet.nam"); nlohmann::json j; - j["version"] = "0.6.1"; + j["version"] = "0.7.0"; j["architecture"] = "SlimmableContainer"; j["config"]["submodels"] = nlohmann::json::array( {{{"max_value", 0.8}, {"model", small_json}}, {{"max_value", 0.5}, {"model", medium_json}}}); @@ -249,7 +261,7 @@ void test_container_sample_rate_mismatch_throws() model_44k["sample_rate"] = 44100; nlohmann::json j; - j["version"] = "0.6.1"; + j["version"] = "0.7.0"; j["architecture"] = "SlimmableContainer"; j["config"]["submodels"] = nlohmann::json::array( {{{"max_value", 0.5}, {"model", model_44k}}, {{"max_value", 1.0}, {"model", model_48k}}}); @@ -301,7 +313,9 @@ void test_container_default_is_max_size() dsp->process(&in_ptr, &out_ptr, buffer_size); // Explicitly set to max - dsp->SetSlimmableSize(1.0); + auto* slimmable = dynamic_cast(dsp.get()); + assert(slimmable != nullptr); + slimmable->SetSlimmableSize(1.0); out_ptr = out_max.data(); dsp->process(&in_ptr, &out_ptr, buffer_size); diff --git a/tools/test/test_render_slim.cpp b/tools/test/test_render_slim.cpp index 8b05ef41..9b3c7ee0 100644 --- a/tools/test/test_render_slim.cpp +++ b/tools/test/test_render_slim.cpp @@ -9,9 +9,9 @@ #include #include -#include "NAM/container.h" #include "NAM/dsp.h" #include "NAM/get_dsp.h" +#include "NAM/slimmable.h" namespace test_render_slim { @@ -25,9 +25,9 @@ void test_slim_changes_output() auto model = nam::get_dsp(std::filesystem::path("example_models/slimmable_container.nam")); assert(model != nullptr); - // Verify it's actually a ContainerModel - auto* container = dynamic_cast(model.get()); - assert(container != nullptr); + // Verify it implements SlimmableModel + auto* slimmable = dynamic_cast(model.get()); + assert(slimmable != nullptr); const double sample_rate = model->GetExpectedSampleRate() > 0 ? model->GetExpectedSampleRate() : 48000.0; const int buffer_size = 64; @@ -40,12 +40,12 @@ void test_slim_changes_output() NAM_SAMPLE* out_ptr; // Render at minimum size - model->SetSlimmableSize(0.0); + slimmable->SetSlimmableSize(0.0); out_ptr = out_small.data(); model->process(&in_ptr, &out_ptr, buffer_size); // Render at maximum size - model->SetSlimmableSize(1.0); + slimmable->SetSlimmableSize(1.0); out_ptr = out_large.data(); model->process(&in_ptr, &out_ptr, buffer_size); @@ -71,9 +71,9 @@ void test_slim_rejects_non_slimmable() auto model = nam::get_dsp(std::filesystem::path("example_models/lstm.nam")); assert(model != nullptr); - // Verify it's NOT a ContainerModel - auto* container = dynamic_cast(model.get()); - assert(container == nullptr); + // Verify it does NOT implement SlimmableModel + auto* slimmable = dynamic_cast(model.get()); + assert(slimmable == nullptr); } // Test that --slim with boundary values produces finite output @@ -93,10 +93,13 @@ void test_slim_boundary_values() NAM_SAMPLE* in_ptr = input.data(); NAM_SAMPLE* out_ptr = output.data(); + auto* slimmable = dynamic_cast(model.get()); + assert(slimmable != nullptr); + double values[] = {0.0, 0.25, 0.5, 0.75, 1.0}; for (double val : values) { - model->SetSlimmableSize(val); + slimmable->SetSlimmableSize(val); model->process(&in_ptr, &out_ptr, buffer_size); for (int i = 0; i < buffer_size; i++) assert(std::isfinite(output[i])); @@ -111,14 +114,14 @@ void test_slim_applied_before_processing() auto model = nam::get_dsp(std::filesystem::path("example_models/slimmable_container.nam")); assert(model != nullptr); - auto* container = dynamic_cast(model.get()); - assert(container != nullptr); + auto* slimmable = dynamic_cast(model.get()); + assert(slimmable != nullptr); const double sample_rate = model->GetExpectedSampleRate() > 0 ? model->GetExpectedSampleRate() : 48000.0; const int buffer_size = 64; // Set slim BEFORE Reset (as render.cpp does it before Reset) - model->SetSlimmableSize(0.5); + slimmable->SetSlimmableSize(0.5); model->Reset(sample_rate, buffer_size); std::vector input(buffer_size, 0.1); From 5b0dcadae6df5d6c50f804240765d34bc8301ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Felipe=20Santos?= Date: Wed, 11 Mar 2026 14:32:13 -0700 Subject: [PATCH 5/5] Fixed core version in docs --- docs/nam_file_version.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nam_file_version.rst b/docs/nam_file_version.rst index 8d19b779..ee8f403a 100644 --- a/docs/nam_file_version.rst +++ b/docs/nam_file_version.rst @@ -31,5 +31,5 @@ The following table shows which versions of NeuralAmpModelerCore support which m - 0.5.3 * - 0.4.0 - 0.6.0 - * - 0.5.0 + * - 0.4.1 - 0.7.0