Skip to content

Commit 3b8dc1c

Browse files
authored
Update README.md
1 parent da929e1 commit 3b8dc1c

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Intel Extension for PyTorch is a Python package to extend official PyTorch. It i
2424
# update submodules for the specified pytorch version
2525
git submodule sync
2626
git submodule update --init --recursive
27-
28-
2927
```
3028

3129
2. Get Intel PyTorch Extension source
@@ -82,7 +80,7 @@ input = torch.randn(2, 4)
8280
model = Model()
8381
res = model(input)
8482
```
85-
If the user want to explore the Intel PyTorch Extension, you just need to transform the above python script as follows.
83+
If you want to explore the Intel PyTorch Extension, you just need to transform the above python script as follows.
8684
```python
8785
import torch
8886
import torch.nn as nn
@@ -103,6 +101,30 @@ input = torch.randn(2, 4).to('dpcpp')
103101
# Convert the model to Intel PyTorch Extension device
104102
model = Model().to('dpcpp')
105103
104+
res = model(input)
105+
```
106+
In addition, Intel PyTorch Extension can auto dispatch an OP to DNNL if the OP is supported with DNNL. Currently, the feature is not enabled by default. If you want to enable the feature, you can refine the above code as follows.
107+
```python
108+
import torch
109+
import torch.nn as nn
110+
111+
# Import Intel PyTorch Extension
112+
import intel_pytorch_extension as ipex
113+
114+
class Model(nn.Module):
115+
def __init__(self):
116+
super(Model, self).__init__()
117+
self.linear = nn.Linear(4, 5)
118+
119+
def forward(self, input):
120+
return self.linear(input)
121+
122+
# Convert the input tensor to Intel PyTorch Extension device
123+
input = torch.randn(2, 4).to('dpcpp')
124+
# Convert the model to Intel PyTorch Extension device
125+
model = Model().to('dpcpp')
126+
127+
ipex.core.enable_auto_dnnl()
106128
res = model(input)
107129
```
108130

0 commit comments

Comments
 (0)