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

Dev add to contiguous kernel #7670

Merged
merged 99 commits into from
Mar 11, 2022
Merged

Conversation

Flowingsun007
Copy link
Contributor

@Flowingsun007 Flowingsun007 commented Mar 3, 2022

  • tensor.contiguous()
  • tensor.is_contiguous()的refine
  • to contiguous 的op/kernel/test case

ncu测试环境

permute oneflow 耗时(us) pytorch耗时(us)
(0,1,3,2) 207.20 206.37
(1,0,2,3) 193.95 193.60
(0,2,3,1) 194.21 193.66
(0,2,1,3) 194.34 192.86
(0,3,2,1) 220.74 219.65
(0,3,1,2) 216.83 214.56

从ncu结果来看,to_contiguous kernel和torch实现接近,差距在1%以内。

@github-actions
Copy link
Contributor

CI failed when running job: cuda-module-distributed-rank-0. PR label automerge has been removed

@Flowingsun007 Flowingsun007 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot March 11, 2022 08:46
@Flowingsun007 Flowingsun007 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot March 11, 2022 12:57
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.6ms (= 12861.2ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 137.3ms (= 13733.3ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.07 (= 137.3ms / 128.6ms)

❌ OneFlow resnet50 time: 78.9ms (= 7892.8ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 86.3ms (= 8630.3ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.09 (= 86.3ms / 78.9ms)

OneFlow resnet50 time: 54.3ms (= 10857.6ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 60.4ms (= 12071.1ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.11 (= 60.4ms / 54.3ms)

OneFlow resnet50 time: 44.3ms (= 8862.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 47.9ms (= 9573.1ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.08 (= 47.9ms / 44.3ms)

OneFlow resnet50 time: 39.4ms (= 7873.5ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 43.7ms (= 8748.4ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.11 (= 43.7ms / 39.4ms)

✔️ OneFlow resnet50 time: 143.0ms (= 14300.5ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 162.7ms (= 16269.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.14 (= 162.7ms / 143.0ms)

OneFlow resnet50 time: 91.8ms (= 9176.4ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 102.8ms (= 10280.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.12 (= 102.8ms / 91.8ms)

OneFlow resnet50 time: 61.4ms (= 12277.8ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 77.5ms (= 15499.9ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.26 (= 77.5ms / 61.4ms)

OneFlow resnet50 time: 51.7ms (= 10346.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 67.0ms (= 13399.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.30 (= 67.0ms / 51.7ms)

OneFlow resnet50 time: 49.0ms (= 9808.4ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 62.5ms (= 12502.1ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.27 (= 62.5ms / 49.0ms)

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.5ms (= 12852.1ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 138.2ms (= 13819.8ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.08 (= 138.2ms / 128.5ms)

✔️ OneFlow resnet50 time: 77.1ms (= 7708.0ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 86.9ms (= 8694.1ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.13 (= 86.9ms / 77.1ms)

OneFlow resnet50 time: 52.1ms (= 10420.4ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 56.9ms (= 11371.4ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.09 (= 56.9ms / 52.1ms)

OneFlow resnet50 time: 44.2ms (= 8835.5ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 49.3ms (= 9854.9ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.12 (= 49.3ms / 44.2ms)

OneFlow resnet50 time: 38.8ms (= 7767.8ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 42.8ms (= 8559.1ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.10 (= 42.8ms / 38.8ms)

✔️ OneFlow resnet50 time: 142.1ms (= 14207.7ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 162.1ms (= 16205.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.14 (= 162.1ms / 142.1ms)

OneFlow resnet50 time: 91.1ms (= 9111.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 107.2ms (= 10716.5ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.18 (= 107.2ms / 91.1ms)

OneFlow resnet50 time: 62.1ms (= 12413.4ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 77.2ms (= 15449.3ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.24 (= 77.2ms / 62.1ms)

OneFlow resnet50 time: 51.3ms (= 10262.2ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 66.1ms (= 13227.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.29 (= 66.1ms / 51.3ms)

OneFlow resnet50 time: 49.8ms (= 9950.9ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 62.6ms (= 12529.1ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.26 (= 62.6ms / 49.8ms)

@Flowingsun007 Flowingsun007 merged commit dd21a00 into master Mar 11, 2022
@Flowingsun007 Flowingsun007 deleted the dev_add_to_contiguous_kernel branch March 11, 2022 23:10
marigoold pushed a commit that referenced this pull request Mar 15, 2022
* view op

* narrow op

* squeeze unsqueeze op

* revert narrow

* refine

* refine

* refine

* format

* kernel impl

* export api interface

* tensor.is_contiguous

* refine

* refine

* fix comments

* mrefine

* refine

* refine

* add todo

* fix comment

* use computeStride

* auto format by CI

* refine

* refine

* refine

* refine

* refine

* support scalar tensor view

* refine

* refint

* refine

* refine

Co-authored-by: oneflow-ci-bot <ci-bot@oneflow.org>
wyg1997 pushed a commit that referenced this pull request Mar 17, 2022
* view op

* narrow op

* squeeze unsqueeze op

* revert narrow

* refine

* refine

* refine

* format

* kernel impl

* export api interface

* tensor.is_contiguous

* refine

* refine

* fix comments

* mrefine

* refine

* refine

* add todo

* fix comment

* use computeStride

* auto format by CI

* refine

* refine

* refine

* refine

* refine

* support scalar tensor view

* refine

* refint

* refine

* refine

Co-authored-by: oneflow-ci-bot <ci-bot@oneflow.org>
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.

6 participants