"driver/driver.cpp" did not exist on "7faf269c995e5594935a16dfdae75a49f62f4991"
Unverified Commit c22dc0fc authored by Jiahang Xu's avatar Jiahang Xu Committed by GitHub
Browse files

[Doc] Refine hardware-aware NAS doc (#4750)

parent 96d30baf
...@@ -18,17 +18,21 @@ Then run multi-trail SPOS demo: ...@@ -18,17 +18,21 @@ Then run multi-trail SPOS demo:
.. code-block:: bash .. code-block:: bash
python ${NNI_ROOT}/examples/nas/oneshot/spos/multi_trial.py cd ${NNI_ROOT}/examples/nas/oneshot/spos/
python search.py --latency-filter cortexA76cpu_tflite21
How the demo works How the demo works
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
To support hardware-aware NAS, you first need a ``Strategy`` that supports filtering the models by latency. We provide such a filter named ``LatencyFilter`` in NNI and initialize a ``Random`` strategy with the filter: To support hardware-aware NAS, you first need a ``Strategy`` that supports filtering the models by latency. We provide such a filter named ``LatencyFilter`` in NNI and initialize a ``RegularizedEvolution`` strategy with the filter:
.. code-block:: python .. code-block:: python
simple_strategy = strategy.Random(model_filter=LatencyFilter(threshold=100, predictor=base_predictor)) evolution_strategy = strategy.RegularizedEvolution(
model_filter=latency_filter,
sample_size=args.evolution_sample_size, population_size=args.evolution_population_size, cycles=args.evolution_cycles
)
``LatencyFilter`` will predict the models\' latency by using nn-Meter and filter out the models whose latency are larger than the threshold (i.e., ``100`` in this example). ``LatencyFilter`` will predict the models\' latency by using nn-Meter and filter out the models whose latency are larger than the threshold (i.e., ``100`` in this example).
You can also build your own strategies and filters to support more flexible NAS such as sorting the models according to latency. You can also build your own strategies and filters to support more flexible NAS such as sorting the models according to latency.
...@@ -37,15 +41,15 @@ Then, pass this strategy to ``RetiariiExperiment``: ...@@ -37,15 +41,15 @@ Then, pass this strategy to ``RetiariiExperiment``:
.. code-block:: python .. code-block:: python
exp = RetiariiExperiment(base_model, trainer, strategy=simple_strategy) exp = RetiariiExperiment(base_model, evaluator, strategy=evolution_strategy)
exp_config = RetiariiExeConfig('local') exp_config = RetiariiExeConfig('local')
... ...
exp_config.dummy_input = [1, 3, 32, 32] exp_config.dummy_input = [1, 3, 224, 224]
exp.run(exp_config, port) exp.run(exp_config, args.port)
In ``exp_config``, ``dummy_input`` is required for tracing shape info. In ``exp_config``, ``dummy_input`` is required for tracing shape info in latency predictor.
End-to-end ProxylessNAS with Latency Constraints End-to-end ProxylessNAS with Latency Constraints
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment