|
1 |
| -diff --git a/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/Intel_Extension_For_PyTorch_Hello_World.py b/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/Intel_Extension_For_PyTorch_Hello_World.py |
2 |
| -index 00eb371b..a3ded045 100755 |
3 |
| ---- a/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/Intel_Extension_For_PyTorch_Hello_World.py |
4 |
| -+++ b/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/Intel_Extension_For_PyTorch_Hello_World.py |
5 |
| -@@ -75,7 +75,7 @@ def main(): |
6 |
| - 3. crite: Criterion function to minimize loss |
7 |
| - ''' |
8 |
| - model = TestModel() |
9 |
| -- model = model.to(memory_format=torch.channels_last) |
10 |
| -+ model = model.to("xpu", memory_format=torch.channels_last) |
11 |
| - optim = torch.optim.SGD(model.parameters(), lr=0.01) |
12 |
| - crite = nn.MSELoss(reduction='sum') |
| 1 | +diff --git a/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script.py b/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script_gpu.py |
| 2 | +similarity index 92% |
| 3 | +rename from AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script.py |
| 4 | +rename to AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script_gpu.py |
| 5 | +index dae594af..edd0fcb3 100644 |
| 6 | +--- a/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script.py |
| 7 | ++++ b/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script_gpu.py |
| 8 | +@@ -23,8 +23,8 @@ def main(args): |
13 | 9 |
|
14 |
| -@@ -104,7 +104,8 @@ def main(): |
15 |
| - ''' |
16 |
| - model.train() |
17 |
| - for batch_index, (data, y_ans) in enumerate(trainLoader): |
18 |
| -- data = data.to(memory_format=torch.channels_last) |
19 |
| -+ data = data.to("xpu", memory_format=torch.channels_last) |
20 |
| -+ y_ans = y_ans.to("xpu", memory_format=torch.channels_last) |
21 |
| - optim.zero_grad() |
22 |
| - y = model(data) |
23 |
| - loss = crite(y, y_ans) |
24 |
| -@@ -116,7 +117,7 @@ def main(): |
25 |
| - ''' |
26 |
| - model.eval() |
27 |
| - for batch_index, data in enumerate(testLoader): |
28 |
| -- data = data.to(memory_format=torch.channels_last) |
29 |
| -+ data = data.to("xpu", memory_format=torch.channels_last) |
30 |
| - y = model(data) |
| 10 | + import intel_extension_for_pytorch as ipex |
31 | 11 |
|
32 |
| - if __name__ == '__main__': |
| 12 | +- model = model.to(memory_format=torch.channels_last) |
| 13 | +- data = data.to(memory_format=torch.channels_last) |
| 14 | ++ model = model.to("xpu",memory_format=torch.channels_last) |
| 15 | ++ data = data.to("xpu",memory_format=torch.channels_last) |
| 16 | + |
| 17 | + if args.dtype == 'float32': |
| 18 | + model = ipex.optimize(model, dtype=torch.float32) |
0 commit comments