Skip to content

[FEATURE] Slimmable model interface #239

@sdatkinson

Description

@sdatkinson

Ship an abstraction for slimmable models.

The main public method that is defined is:

void SetSlimmableSize(const double val)

val is assumed to be between 0.0 (minimum size) and 1.0 (maximum size).

The method is not real-time safe. When it is called, the object (whose class also presumably inherits from nam::DSP) should take any necessary steps to prepare itself to .Process() in a new way.

For example, one could imagine a "container" model inside which there are several pre-loaded NAMs (A1-standard, lite, feather, nano?). Its Process function might look like a pass-through to a "hot" model:

void ContainerModel::Process(NAM_SAMPLE** input, NAM_SAMPLE** output, const int num_frames)
{
  mActive->Process(input, output, num_frames);
}

and similar for other public methods. When the SetSlimmableSize method is called, an internal pointer is set to the appropriate model e.g.:

void ContainerModel::SetSlimmableSize(const double val)
{
  if (val < 0.25) {
    mNano->Reset(GetExpectedSampleRate(), mMaxBufferSize);
    mActive = mNano;
  }
  else if (val < 0.5) {
    mFeather->Reset(GetExpectedSampleRate(), mMaxBufferSize);
    mActive = mFeather;
  }
  else if (val < <0.75) {
    mLite->Reset(GetExpectedSampleRate(), mMaxBufferSize);
    mActive = mLite;
  }
  else {
    mStandard->Reset(GetExpectedSampleRate(), mMaxBufferSize);
    mActive = mStandard;
  }
}

This is different from the interface defined in SlimmableNamDsp in that I'm opting for a "continuous" parameter in order to make the presentation more unified for models of different sizes (the paper used a model with max size of 8 channels for demonstration purposes) as well as to make way for other interesting implementations of slimming instead of channel slicing like I did in the paper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions