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

tensor add storage method #10311

Merged
merged 3 commits into from
Aug 9, 2023
Merged

tensor add storage method #10311

merged 3 commits into from
Aug 9, 2023

Conversation

Ldpe2G
Copy link
Contributor

@Ldpe2G Ldpe2G commented Aug 8, 2023

对齐 torch 给tensor添加 storage 方法

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

Code got formatted by CI. Please request CI again if you still want to have this PR merged. If the PR is from a forked repo, please download the patch files from the GitHub Actions web page and apply them locally.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/10311/

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

Speed stats:
GPU Name: NVIDIA GeForce RTX 3080 Ti 

❌ OneFlow resnet50 time: 43.8ms (= 4382.6ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 57.3ms (= 5729.4ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.31 (= 57.3ms / 43.8ms)

OneFlow resnet50 time: 26.2ms (= 2615.7ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 37.8ms (= 3784.1ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.45 (= 37.8ms / 26.2ms)

OneFlow resnet50 time: 20.6ms (= 4122.0ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 35.6ms (= 7126.1ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.73 (= 35.6ms / 20.6ms)

OneFlow resnet50 time: 18.3ms (= 3653.0ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 31.3ms (= 6260.0ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.71 (= 31.3ms / 18.3ms)

OneFlow resnet50 time: 17.3ms (= 3468.8ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 28.8ms (= 5753.4ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.66 (= 28.8ms / 17.3ms)

OneFlow swin dataloader time: 0.200s (= 40.093s / 200, num_workers=1)
PyTorch swin dataloader time: 0.128s (= 25.673s / 200, num_workers=1)
Relative speed: 0.640 (= 0.128s / 0.200s)

OneFlow swin dataloader time: 0.056s (= 11.121s / 200, num_workers=4)
PyTorch swin dataloader time: 0.033s (= 6.536s / 200, num_workers=4)
Relative speed: 0.588 (= 0.033s / 0.056s)

OneFlow swin dataloader time: 0.031s (= 6.202s / 200, num_workers=8)
PyTorch swin dataloader time: 0.017s (= 3.355s / 200, num_workers=8)
Relative speed: 0.541 (= 0.017s / 0.031s)

❌ OneFlow resnet50 time: 47.7ms (= 4768.6ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.2ms (= 6422.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.35 (= 64.2ms / 47.7ms)

OneFlow resnet50 time: 31.6ms (= 3155.6ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 46.2ms (= 4618.1ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.46 (= 46.2ms / 31.6ms)

OneFlow resnet50 time: 24.1ms (= 4823.8ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 40.5ms (= 8103.0ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.68 (= 40.5ms / 24.1ms)

OneFlow resnet50 time: 22.8ms (= 4565.0ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 36.9ms (= 7383.7ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.62 (= 36.9ms / 22.8ms)

OneFlow resnet50 time: 19.6ms (= 3911.9ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 34.0ms (= 6805.9ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.74 (= 34.0ms / 19.6ms)

@@ -533,6 +533,10 @@ def _conj_physical(self):
return flow._C.conj_physical(self)


def _storage(self):
return self
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 tensor 貌似内部还没有 storage 这个接口暴露出来,而是直接有个 data_ptr

{"data_ptr", PyTensorObject_data_ptr, METH_NOARGS, NULL},

@Ldpe2G Ldpe2G requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 8, 2023 07:47
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/10311/

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

Speed stats:
GPU Name: NVIDIA GeForce RTX 3080 Ti 

❌ OneFlow resnet50 time: 43.1ms (= 4314.9ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 61.3ms (= 6131.0ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.42 (= 61.3ms / 43.1ms)

OneFlow resnet50 time: 25.8ms (= 2577.1ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 37.7ms (= 3767.2ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.46 (= 37.7ms / 25.8ms)

OneFlow resnet50 time: 19.0ms (= 3794.5ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 36.0ms (= 7209.4ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.90 (= 36.0ms / 19.0ms)

OneFlow resnet50 time: 19.4ms (= 3878.5ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 31.9ms (= 6374.3ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.64 (= 31.9ms / 19.4ms)

OneFlow resnet50 time: 18.1ms (= 3612.3ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 29.3ms (= 5860.5ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.62 (= 29.3ms / 18.1ms)

OneFlow swin dataloader time: 0.202s (= 40.302s / 200, num_workers=1)
PyTorch swin dataloader time: 0.129s (= 25.712s / 200, num_workers=1)
Relative speed: 0.638 (= 0.129s / 0.202s)

OneFlow swin dataloader time: 0.056s (= 11.196s / 200, num_workers=4)
PyTorch swin dataloader time: 0.033s (= 6.530s / 200, num_workers=4)
Relative speed: 0.583 (= 0.033s / 0.056s)

OneFlow swin dataloader time: 0.031s (= 6.217s / 200, num_workers=8)
PyTorch swin dataloader time: 0.016s (= 3.287s / 200, num_workers=8)
Relative speed: 0.529 (= 0.016s / 0.031s)

❌ OneFlow resnet50 time: 47.6ms (= 4761.9ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 65.9ms (= 6590.3ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.38 (= 65.9ms / 47.6ms)

OneFlow resnet50 time: 31.0ms (= 3103.3ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 44.5ms (= 4446.7ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.43 (= 44.5ms / 31.0ms)

OneFlow resnet50 time: 24.3ms (= 4866.3ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 43.0ms (= 8606.6ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.77 (= 43.0ms / 24.3ms)

OneFlow resnet50 time: 20.5ms (= 4090.4ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 36.6ms (= 7319.6ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.79 (= 36.6ms / 20.5ms)

OneFlow resnet50 time: 21.2ms (= 4236.2ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 34.1ms (= 6817.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.61 (= 34.1ms / 21.2ms)

@Ldpe2G Ldpe2G merged commit f950a9a into master Aug 9, 2023
20 checks passed
@Ldpe2G Ldpe2G deleted the dev_tensor_add_storage branch August 9, 2023 01:00
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