forked from pytorch/ort
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pytorch#121 from intel-staging/ov_torchort_integra…
…tion_2 Documentation and sample code changes for torch_ort_inference
- Loading branch information
Showing
6 changed files
with
333 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# APIs for OpenVINO™ integration with TorchORT | ||
|
||
This document describes available Python APIs for OpenVINO™ integration with TorchORT to accelerate inference for PyTorch models on various Intel hardware. | ||
|
||
## Essential APIs | ||
|
||
To add the OpenVINO™ integration with TorchORT package to your PyTorch application, add following 2 lines of code: | ||
|
||
```python | ||
from torch_ort import ORTInferenceModule | ||
model = ORTInferenceModule(model) | ||
``` | ||
|
||
By default, CPU backend with FP32 precision is enabled. You can set different backend and supported precision using OpenVINOProviderOptions as below: | ||
|
||
```python | ||
provider_options = OpenVINOProviderOptions(backend = "GPU", precision = "FP16") | ||
model = ORTInferenceModule(model, provider_options = provider_options) | ||
``` | ||
Supported backend-precision combinations: | ||
| Backend | Precision | | ||
| --------| --------- | | ||
| CPU | FP32 | | ||
| GPU | FP32 | | ||
| GPU | FP16 | | ||
| MYRIAD | FP16 | | ||
|
||
## Additional APIs | ||
|
||
To save the inline exported onnx model, use DebugOptions as below: | ||
|
||
```python | ||
debug_options = DebugOptions(save_onnx=True, onnx_prefix='<model_name>') | ||
model = ORTInferenceModule(model, debug_options=debug_options) | ||
``` | ||
|
||
To enable verbose log of the execution of the TorchORT pipeline, use DebugOptions as below: | ||
|
||
```python | ||
debug_options = DebugOptions(log_level=LogLevel.VERBOSE) | ||
model = ORTInferenceModule(model, debug_options=debug_options) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.