You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-8Lines changed: 46 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,68 @@
1
1
# Intel® Extension for PyTorch\*
2
2
3
-
Intel® Extension for PyTorch\* extends PyTorch with optimizations for extra performance boost on Intel hardware. Most of the optimizations will be included in stock PyTorch releases eventually, and the intention of the extension is to deliver up-to-date features and optimizations for PyTorch on Intel hardware, examples include AVX-512 Vector Neural Network Instructions (AVX512 VNNI) and Intel® Advanced Matrix Extensions (Intel® AMX).
3
+
Intel® Extension for PyTorch\* extends PyTorch with up-to-date features optimizations for an extra performance boost on Intel hardware. Example optimizations use AVX-512 Vector Neural Network Instructions (AVX512 VNNI) and Intel® Advanced Matrix Extensions (Intel® AMX). Over time, most of these optimizations will be included directly into stock PyTorch releases. More importantly, Intel® Extension for PyTorch\* provides easy GPU acceleration for Intel® discrete graphics cards with PyTorch\*.
4
4
5
-
Intel® Extension for PyTorch\*is loaded as a Python module for Python programs or linked as a C++ library for C++ programs. Users can enable it dynamically in script by importing `intel_extension_for_pytorch`. It covers optimizations for both imperative mode and graph mode. Optimized operators and kernels are registered through PyTorch dispatching mechanism. These operators and kernels are accelerated from native vectorization feature and matrix calculation feature of Intel hardware. During execution, Intel® Extension for PyTorch\* intercepts invocation of ATen operators, and replace the original ones with these optimized ones. In graph mode, further operator fusions are applied manually by Intel engineers or through a tool named *oneDNN Graph* to reduce operator/kernel invocation overheads, and thus increase performance.
5
+
Intel® Extension for PyTorch\*provides optimizations for both eager mode and graph mode, however, compared to eager mode, graph mode in PyTorch normally yields better performance from optimization techniques such as operation fusion, and Intel® Extension for PyTorch\* amplified them with more comprehensive graph optimizations. Therefore we recommended you to take advantage of Intel® Extension for PyTorch\* with [TorchScript](https://pytorch.org/docs/stable/jit.html) whenever your workload supports it. You could choose to run with `torch.jit.trace()` function or `torch.jit.script()` function, but based on our evaluation, `torch.jit.trace()` supports more workloads so we recommend you to use `torch.jit.trace()` as your first choice. On Intel® graphics cards, through registering feature implementations into PyTorch\* as torch.xpu, PyTorch\* scripts work on Intel® discrete graphics cards.
6
6
7
-
More detailed tutorials are available at [**Intel® Extension for PyTorch\* online document website**](https://intel.github.io/intel-extension-for-pytorch/).
7
+
The extension can be loaded as a Python module for Python programs or linked as a C++ library for C++ programs. In Python scripts users can enable it dynamically by importing `intel_extension_for_pytorch`.
8
+
9
+
More detailed tutorials are available at **Intel® Extension for PyTorch\* online document website**. Both [CPU version](https://intel.github.io/intel-extension-for-pytorch/cpu/latest/) and [XPU/GPU version](https://intel.github.io/intel-extension-for-pytorch/xpu/latest/) are available.
8
10
9
11
## Installation
10
12
11
-
You can use either of the following 2 commands to install Intel® Extension for PyTorch\*.
13
+
### CPU version
14
+
15
+
You can use either of the following 2 commands to install Intel® Extension for PyTorch\* CPU version.
**Note:** Intel® Extension for PyTorch\* has PyTorch version requirement. Please check more detailed information via the URL below.
22
26
23
-
More installation methods can be found at [Installation Guide](https://intel.github.io/intel-extension-for-pytorch/latest/tutorials/installation.html)
27
+
More installation methods can be found at [CPU Installation Guide](https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/installation.html)
28
+
29
+
### XPU/GPU version
30
+
31
+
You can install Intel® Extension for PyTorch\* for XPU/GPU via command below.
**Note:** The patched PyTorch 1.10.0a0 is required to work with Intel® Extension for PyTorch\* on Intel® graphics card for now.
39
+
40
+
More installation methods can be found at [XPU/GPU Installation Guide](https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/installation.html)
24
41
25
42
## Getting Started
26
43
27
44
Minor code changes are required for users to get start with Intel® Extension for PyTorch\*. Both PyTorch imperative mode and TorchScript mode are supported. You just need to import Intel® Extension for PyTorch\* package and apply its optimize function against the model object. If it is a training workload, the optimize function also needs to be applied against the optimizer object.
28
45
29
-
The following code snippet shows an inference code with FP32 data type. More examples, including training and C++ examples, are available at [Example page](https://intel.github.io/intel-extension-for-pytorch/latest/tutorials/examples.html).
46
+
The following code snippet shows an inference code with FP32 data type. More examples on CPU, including training and C++ examples, are available at [CPU Example page](https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/examples.html). More examples on XPU/GPU are available at [XPU/GPU Example page](https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/examples.html).
47
+
48
+
### Inference on CPU
49
+
50
+
```python
51
+
import torch
52
+
import torchvision.models as models
53
+
54
+
model = models.resnet50(pretrained=True)
55
+
model.eval()
56
+
data = torch.rand(1, 3, 224, 224)
57
+
58
+
import intel_extension_for_pytorch as ipex
59
+
model = ipex.optimize(model)
60
+
61
+
with torch.no_grad():
62
+
model(data)
63
+
```
64
+
65
+
### Inference on GPU
30
66
31
67
```python
32
68
import torch
@@ -37,6 +73,8 @@ model.eval()
37
73
data = torch.rand(1, 3, 224, 224)
38
74
39
75
import intel_extension_for_pytorch as ipex
76
+
model.to('xpu')
77
+
data.to('xpu')
40
78
model = ipex.optimize(model)
41
79
42
80
with torch.no_grad():
@@ -45,7 +83,7 @@ with torch.no_grad():
45
83
46
84
## Model Zoo
47
85
48
-
Use cases that had already been optimized by Intel engineers are available at [Model Zoo for Intel® Architecture](https://github.com/IntelAI/models/tree/pytorch-r1.12-models). A bunch of PyTorch use cases for benchmarking are also available on the [Github page](https://github.com/IntelAI/models/tree/pytorch-r1.12-models/benchmarks#pytorch-use-cases). You can get performance benefits out-of-box by simply running scipts in the Model Zoo.
86
+
Use cases that had already been optimized by Intel engineers are available at [Model Zoo for Intel® Architecture](https://github.com/IntelAI/models/tree/pytorch-r1.13-models). A bunch of PyTorch use cases for benchmarking are also available on the [Github page](https://github.com/IntelAI/models/tree/pytorch-r1.13-models/benchmarks#pytorch-use-cases). You can get performance benefits out-of-box by simply running scipts in the Model Zoo.
0 commit comments