diff --git a/README.md b/README.md index 31b5670..26da503 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ pip3 install git+https://github.com/ENOT-AutoDL/ti-vit.git@main To export the model version with maximum performance, run the following command: ```commandline -export-ti-vit -o npu-max-perf.onnx -t npu-max-perf +export-ti-vit -o max-perf.onnx -t max-perf ``` This variant of model contains MLP blocks that can be run on TI DSP. GELU operation is approximated. @@ -24,7 +24,7 @@ This variant of model contains MLP blocks that can be run on TI DSP. GELU operat To export the model version with minimal loss of accuracy, run the following command: ```commandline -export-ti-vit -o npu-max-acc.onnx -t npu-max-acc +export-ti-vit -o max-acc.onnx -t max-acc ``` This variant of model contains MLP blocks that partially can be run on TI DSP. GELU operation is not approximated. @@ -33,3 +33,15 @@ This variant of model contains MLP blocks that partially can be run on TI DSP. G It is important to disable compilation of all nodes except nodes from MLP blocks ("Squeeze" node from MLP must be disabled too). The list of operations for ["deny_list:layer_name"](https://github.com/TexasInstruments/edgeai-tidl-tools/blob/08_06_00_05/examples/osrt_python/README.md#options-to-enable-control-on-layer-level-delegation-to-ti-dsparm) compiler option can be found in the file "output-onnx-dir/output-onnx-name.deny_list", that is generated with onnx file. + +## Results + +### TorchVision ViT B16 +| | CPU only | max-acc | max-perf | +|----------|----------|---------|----------| +| Time sec | 3.398 | 2.233 | 1.382 | + +### ENOT optimized ViT B16 +| | CPU only | max-acc | max-perf | +|----------|----------|---------|----------| +| Time sec | 0.871 | 0.574 | 0.361 | \ No newline at end of file diff --git a/src/ti_vit/export.py b/src/ti_vit/export.py index a708876..6ca0ae0 100644 --- a/src/ti_vit/export.py +++ b/src/ti_vit/export.py @@ -31,7 +31,7 @@ def export( output_onnx_path : Union[str, Path] Path to the output ONNX file. model_type : str - Type of the final model. Possible values are "npu-max-acc", "npu-max-perf" or "cpu". + Type of the final model. Possible values are "max-acc", "max-perf" or "cpu". checkpoint_path : Optional[Union[str, Path]] = None Path to the PyTorch model checkpoint. If value is None, then ViT_B_16 pretrained torchvision model is used. Default value is None. @@ -49,9 +49,9 @@ def export( try: transform_model_func = { "cpu": lambda model: model, - "npu-max-acc": TICompatibleVitOrtMaxAcc, - "npu-max-perf": lambda model: TICompatibleVitOrtMaxPerf(model=model, ignore_tidl_errors=False), - "npu-max-perf-experimental": lambda model: TICompatibleVitOrtMaxPerf(model=model, ignore_tidl_errors=True), + "max-acc": TICompatibleVitOrtMaxAcc, + "max-perf": lambda model: TICompatibleVitOrtMaxPerf(model=model, ignore_tidl_errors=False), + "max-perf-experimental": lambda model: TICompatibleVitOrtMaxPerf(model=model, ignore_tidl_errors=True), }[model_type] except KeyError as exc: raise ValueError(f"Got unknown transformation type ('{model_type}')") from exc @@ -105,9 +105,9 @@ def export_ti_compatible_vit() -> None: # pylint: disable=missing-function-docs "--model-type", type=str, required=False, - default="npu-max-perf", - help='Type of the final model (optional argument). Possible values are "npu-max-acc", "npu-max-perf", or "cpu".' - ' Default value is "npu-max-perf".', + default="max-perf", + help='Type of the final model (optional argument). Possible values are "max-acc", "max-perf", or "cpu".' + ' Default value is "max-perf".', ) parser.add_argument( "-c",