Here we show how to develop new NAS algorithms with an example of SPOS.
1. Register a new algorithm
Create a new file `mmrazor/models/algorithms/nas/spos.py`, class `SPOS` inherits from class `BaseAlgorithm`
```Python
from mmrazor.registry import MODELS
from ..base import BaseAlgorithm
@MODELS.register_module()
class SPOS(BaseAlgorithm):
def __init__(self, **kwargs):
super(SPOS, self).__init__(**kwargs)
pass
def loss(self, batch_inputs, data_samples):
pass
```
2. Develop new algorithm components (optional)
SPOS can directly use class `OneShotModuleMutator` as core functions provider. If mutators provided in MMRazor don’t meet your needs, you can develop new algorithm components for your algorithm like `OneShotModuleMutator`, we will take `OneShotModuleMutator` as an example to introduce how to develop a new algorithm component:
a. Create a new file `mmrazor/models/mutators/module_mutator/one_shot_module_mutator.py`, class `OneShotModuleMutator` inherits from class `ModuleMutator`
b. Finish the functions you need in `OneShotModuleMutator`, eg: `sample_choices`, `set_choices` and so on.