Skip to content
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

Optimize nchw Avgpool #7451

Merged
merged 6 commits into from
Feb 21, 2022
Merged

Optimize nchw Avgpool #7451

merged 6 commits into from
Feb 21, 2022

Conversation

MARD1NO
Copy link
Contributor

@MARD1NO MARD1NO commented Feb 9, 2022

测试平台:

A100,cuda11.4

pool type shape of time torch time
avgpool1d forward 32 * 64 * (112 * 112) 179.68us 285.47us
avgpool1d backward 32 * 64 * (112 * 112) 349.54us 1360us
avgpool2d forward 32 * 64 * 112 * 112 188.32us 207.49us
avgpool2d backward 32 * 64 * 112 * 112 479.55us 1710us
avgpool3d forward 32 * 32 * 64 * 32 * 64 949.76us 1240us
avgpool3d backward 32 * 32 * 64 * 32 * 64 3160us 3250us

@MARD1NO MARD1NO marked this pull request as ready for review February 10, 2022 01:57
@lixiang007666 lixiang007666 self-requested a review February 11, 2022 09:41
AvgPoolingKernelUtil<device_type, T>::Avgpool2dForward(ctx->stream(), index_helper, elem_num,
src, dest, params_3d);
DimVector y_vector(3);
y_vector.at(0) = y->shape().At(0) * y->shape().At(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这几处改动,是维度折叠相关的优化吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的

@oneflow-ci-bot oneflow-ci-bot removed their request for review February 21, 2022 06:32
@oneflow-ci-bot oneflow-ci-bot self-requested a review February 21, 2022 07:18
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 21, 2022 09:55
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 21, 2022 14:46
@oneflow-ci-bot oneflow-ci-bot self-requested a review February 21, 2022 17:57
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.5ms (= 12851.6ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 141.9ms (= 14187.0ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.10 (= 141.9ms / 128.5ms)

✔️ OneFlow resnet50 time: 77.4ms (= 7736.4ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 81.4ms (= 8142.9ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.05 (= 81.4ms / 77.4ms)

OneFlow resnet50 time: 51.4ms (= 10288.7ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 54.1ms (= 10814.2ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.05 (= 54.1ms / 51.4ms)

OneFlow resnet50 time: 42.2ms (= 8434.7ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 47.2ms (= 9434.0ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.12 (= 47.2ms / 42.2ms)

OneFlow resnet50 time: 38.6ms (= 7720.0ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 41.5ms (= 8306.2ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.08 (= 41.5ms / 38.6ms)

✔️ OneFlow resnet50 time: 139.9ms (= 13992.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 157.9ms (= 15794.5ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.13 (= 157.9ms / 139.9ms)

OneFlow resnet50 time: 89.7ms (= 8965.6ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 100.4ms (= 10035.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.12 (= 100.4ms / 89.7ms)

OneFlow resnet50 time: 60.2ms (= 12045.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 80.2ms (= 16046.7ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.33 (= 80.2ms / 60.2ms)

OneFlow resnet50 time: 54.6ms (= 10924.5ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.3ms (= 12854.0ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.18 (= 64.3ms / 54.6ms)

OneFlow resnet50 time: 46.8ms (= 9361.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 62.1ms (= 12423.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.33 (= 62.1ms / 46.8ms)

@oneflow-ci-bot oneflow-ci-bot merged commit b20eaa7 into master Feb 21, 2022
@oneflow-ci-bot oneflow-ci-bot deleted the optimize_nchw_avgpool branch February 21, 2022 19:51
marigoold pushed a commit that referenced this pull request Mar 15, 2022
Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants