Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme: added results section #3

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ 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.

### MLP blocks partially on TI DSP (minimal loss of accuracy)

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.

Expand All @@ -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 |
14 changes: 7 additions & 7 deletions src/ti_vit/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Loading