-
Notifications
You must be signed in to change notification settings - Fork 743
fix resnet inference demo link from ipex repo #1339
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
46 changes: 16 additions & 30 deletions
46
...ting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/codes_for_ipynb/gpu.patch
This file contains hidden or 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 |
|---|---|---|
| @@ -1,32 +1,18 @@ | ||
| 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 | ||
| index 00eb371b..a3ded045 100755 | ||
| --- 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 | ||
| @@ -75,7 +75,7 @@ def main(): | ||
| 3. crite: Criterion function to minimize loss | ||
| ''' | ||
| model = TestModel() | ||
| - model = model.to(memory_format=torch.channels_last) | ||
| + model = model.to("xpu", memory_format=torch.channels_last) | ||
| optim = torch.optim.SGD(model.parameters(), lr=0.01) | ||
| crite = nn.MSELoss(reduction='sum') | ||
| 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 | ||
| similarity index 92% | ||
| rename from AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script.py | ||
| rename to AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/resnet50_general_inference_script_gpu.py | ||
| index dae594af..edd0fcb3 100644 | ||
| --- 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 | ||
| @@ -23,8 +23,8 @@ def main(args): | ||
|
|
||
| @@ -104,7 +104,8 @@ def main(): | ||
| ''' | ||
| model.train() | ||
| for batch_index, (data, y_ans) in enumerate(trainLoader): | ||
| - data = data.to(memory_format=torch.channels_last) | ||
| + data = data.to("xpu", memory_format=torch.channels_last) | ||
| + y_ans = y_ans.to("xpu", memory_format=torch.channels_last) | ||
| optim.zero_grad() | ||
| y = model(data) | ||
| loss = crite(y, y_ans) | ||
| @@ -116,7 +117,7 @@ def main(): | ||
| ''' | ||
| model.eval() | ||
| for batch_index, data in enumerate(testLoader): | ||
| - data = data.to(memory_format=torch.channels_last) | ||
| + data = data.to("xpu", memory_format=torch.channels_last) | ||
| y = model(data) | ||
| import intel_extension_for_pytorch as ipex | ||
|
|
||
| if __name__ == '__main__': | ||
| - model = model.to(memory_format=torch.channels_last) | ||
| - data = data.to(memory_format=torch.channels_last) | ||
| + model = model.to("xpu",memory_format=torch.channels_last) | ||
| + data = data.to("xpu",memory_format=torch.channels_last) | ||
|
|
||
| if args.dtype == 'float32': | ||
| model = ipex.optimize(model, dtype=torch.float32) |
32 changes: 32 additions & 0 deletions
32
...Getting-Started-Samples/Intel_Extension_For_PyTorch_GettingStarted/codes_for_py/gpu.patch
This file contains hidden or 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,32 @@ | ||
| 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 | ||
| index 00eb371b..a3ded045 100755 | ||
| --- 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 | ||
| @@ -75,7 +75,7 @@ def main(): | ||
| 3. crite: Criterion function to minimize loss | ||
| ''' | ||
| model = TestModel() | ||
| - model = model.to(memory_format=torch.channels_last) | ||
| + model = model.to("xpu", memory_format=torch.channels_last) | ||
| optim = torch.optim.SGD(model.parameters(), lr=0.01) | ||
| crite = nn.MSELoss(reduction='sum') | ||
|
|
||
| @@ -104,7 +104,8 @@ def main(): | ||
| ''' | ||
| model.train() | ||
| for batch_index, (data, y_ans) in enumerate(trainLoader): | ||
| - data = data.to(memory_format=torch.channels_last) | ||
| + data = data.to("xpu", memory_format=torch.channels_last) | ||
| + y_ans = y_ans.to("xpu", memory_format=torch.channels_last) | ||
| optim.zero_grad() | ||
| y = model(data) | ||
| loss = crite(y, y_ans) | ||
| @@ -116,7 +117,7 @@ def main(): | ||
| ''' | ||
| model.eval() | ||
| for batch_index, data in enumerate(testLoader): | ||
| - data = data.to(memory_format=torch.channels_last) | ||
| + data = data.to("xpu", memory_format=torch.channels_last) | ||
| y = model(data) | ||
|
|
||
| if __name__ == '__main__': | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when do we apply this patch?
should we mention how to use this patch in README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this patch is prepared when customer want to train with the Intel_Extension_For_Pytorch_GettingStarted.py file on XPU, so they can use this patch to quickly change to xpu demo.
Yeah, if we add this patch, maybe we should also add the instruction in README to tell customer what this is for, I will add it, or do you prefer to remove it?