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
add channels last for MaxPool2d #48917
Conversation
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU [ghstack-poisoned]
use this one to replace #42719 This patch adds channels last memory format support for Performance result on CPU Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz, 2*20 cores, comparing CL v.s. contiguous:
input size is picked up from RN50. Use this script to reproduce, ### (before)
### using OMP_NUM_THREADS=1
MaxPool2d(contiguous): input_size [1, 64, 112, 112] time: 5.317 ms
### using OMP_NUM_THREADS=20
MaxPool2d(contiguous): input_size [1, 64, 112, 112] time: 6.443 ms
MaxPool2d(contiguous): input_size [128, 64, 112, 112] time: 45.178 ms
### (after)
### using OMP_NUM_THREADS=1
MaxPool2d(contiguous): input_size [1, 64, 112, 112] time: 5.304 ms
MaxPool2d(channels_last): input_size [1, 64, 112, 112] time: 0.544 ms
### using OMP_NUM_THREADS=20
MaxPool2d(contiguous): input_size [1, 64, 112, 112] time: 0.336 ms
MaxPool2d(channels_last): input_size [1, 64, 112, 112] time: 0.102 ms
MaxPool2d(contiguous): input_size [128, 64, 112, 112] time: 42.141 ms
MaxPool2d(channels_last): input_size [128, 64, 112, 112] time: 15.897 ms
|
Fails internally on Android VR build:
|
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
@VitalyFedyunin, the android build failure has been fixed, please check! |
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
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.
Hello! I finished with OneDDN PRs and moving to this stack. Meanwhile can you please add vec256 test for new function.
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
Sorry, merge conflicts with just landed #54898 , please rebase again |
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU Differential Revision: [D25399470](https://our.internmc.facebook.com/intern/diff/D25399470) [ghstack-poisoned]
@VitalyFedyunin updated! |
@VitalyFedyunin merged this pull request in f43eb59. |
Seems like this broke ios build MaxPoolKernel.cpp |
This pull request has been reverted by 978fca6. |
working on it. |
I can't reproduce the build failure on this patch on iOS. BUILD_PYTORCH_MOBILE=1 IOS_PLATFORM=SIMULATOR ./scripts/build_ios.sh I built on both iOS and MacOS and both succeeded.
About the failure from https://app.circleci.com/pipelines/github/pytorch/pytorch/295279/workflows/5f586a11-d066-46a7-a085-9b72258ce6bc/jobs/12076475 The thing that goes wrong is
I don't understand why both @VitalyFedyunin About the failed CI, is there any special build recipe for it? |
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU ghstack-source-id: 039bb43d75a3df01fdc47cb53c96d6961cfda3f0 Pull Request resolved: pytorch#48917
int kW, int kH, int dW, int dH, int padW, int padH, int dilationW, int dilationH); | ||
using max_pool2d_backward_fn = void(*)(Tensor& grad_input, const Tensor& grad_output, const Tensor& indices); | ||
|
||
DECLARE_DISPATCH(max_pool2d_fn, max_pool2d_kernel); |
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.
I think this PR misses a DEFINE_DISPATCH
call in one of .cpp files
int64_t ow = 0; | ||
data_index_init(begin, c, channels, oh, output_height, ow, output_width); | ||
|
||
for (int64_t i = begin; i < end; i++) { |
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.
Can c10::irange
be used here?
@mingfeima lets try to figure out what is going on here. Could you please create this change as separate PR (do NOT abandon stack) and add Also please add |
This only happens when Lite interpreter is build, i.e. when pytorch/tools/build_variables.bzl Line 759 in bbdb37b
@cccclai Can you please explain why this must be an explicit list instead of glob? |
Yes the recipe is to build lite interpreter is here: https://pytorch.org/tutorials/prototype/lite_interpreter.html. To build for ios, the command is:
|
The main reason is to pick the files needed for pytorch edge, such that we can build a library with smaller size (lite interpreter). Some resources from aten are not needed when deploying for mobile. |
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU ghstack-source-id: 2f2487b881ab8080b261d07fc87c46fcef59b8a0 Pull Request resolved: #48917
max_pool2d channels last support forward path max_pool2d channels last support backward path vectorize channels last forward path rename the header file fix windows build combine PoolingKernel.h into Pool.h add data type check loosen test_max_pool2d_nhwc to cover device CPU ghstack-source-id: 2f2487b881ab8080b261d07fc87c46fcef59b8a0 Pull Request resolved: pytorch#48917
Summary: add channels last support for MaxPool2d. this one is a replacement of pytorch#48917 Pull Request resolved: pytorch#56361 Reviewed By: heitorschueroff Differential Revision: D27874142 Pulled By: VitalyFedyunin fbshipit-source-id: bc9604def9c974d7b59621fc709a39948088b992
Stack from ghstack:
max_pool2d channels last support forward path
max_pool2d channels last support backward path
vectorize channels last forward path
rename the header file
fix windows build
combine PoolingKernel.h into Pool.h
add data type check
loosen test_max_pool2d_nhwc to cover device CPU
Differential Revision: D25399470