-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Nano: Add support for channels_last #5103
Merged
yangw1234
merged 15 commits into
intel-analytics:main
from
y199387:add-channel-last-support
Jul 20, 2022
Merged
Nano: Add support for channels_last #5103
yangw1234
merged 15 commits into
intel-analytics:main
from
y199387:add-channel-last-support
Jul 20, 2022
Conversation
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
y199387
commented
Jul 18, 2022
class ConvModel(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
self.conv1 = torch.nn.Conv2d(2, 1, (1, 2), bias=False) |
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.
For Convolutional layer with only one channel, the layer.param.is_contiguous() & layer.param.is_contiguous(memory_format=torch.channels_last) is True after the model is converted to channels_last.
you may also rebase on main since we updated the github actions workflows |
y199387
force-pushed
the
add-channel-last-support
branch
from
July 19, 2022 06:17
9a43814
to
edcb900
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This pr Add support for automatically converting model and data's memory_format to channels_last.
If user instantiate
nano.pytorch.Tainer
withchannels_last=True
,the model will be converted to channels_last and its hook functionon_before_batch_transfer
will be replaced atsetup
stage. The replacedon_before_batch_transfer
function will convert every batch to data withmemory_format=channels_last
.1. Why the change?
Channels Last improves the throughput of convolution operations in networks for computer vision. Using channels_last and ipex at the same time can get better acceleration effect. It's
necessary to provide user a simple way to apply
torch.channels
to both of the model object and data.https://github.com/analytics-zoo/nano/issues/170
2. Summary of the change
3. How to test?