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

[primitive] add binary tests #8109

Merged
merged 32 commits into from
May 7, 2022
Merged

[primitive] add binary tests #8109

merged 32 commits into from
May 7, 2022

Conversation

guo-ran
Copy link
Contributor

@guo-ran guo-ran commented Apr 27, 2022

  • binary
    • elemwise: test_type 0
    • broadcast: test_type 1
    • left_scalar: test_type 2
    • right_scalar: test_type 3

#define CPU_PRIMITIVE_BINARY_ONEDNN_TYPE_SEQ \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::s8, DataType::kInt8, int8_t) \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::u8, DataType::kBool, bool) \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::u8, DataType::kUInt8, uint8_t) \
Copy link
Contributor Author

@guo-ran guo-ran May 1, 2022

Choose a reason for hiding this comment

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

onednn实现的int8和uint8类型过不了primitive单测 @luqiang-guo

Copy link
Contributor

Choose a reason for hiding this comment

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

计算策略不同,onednn在溢出的时候是截断处理,torch 直接溢出

@guo-ran guo-ran changed the title [WIP] add primitive unit tests add copy_nd binary softmax primitive unit tests May 1, 2022
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::s8, DataType::kInt8, int8_t) \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::u8, DataType::kBool, bool) \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::u8, DataType::kUInt8, uint8_t) \
OF_PP_MAKE_TUPLE_SEQ(dnnl::memory::data_type::f32, DataType::kFloat, float) \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

float类型过不了left_scalar和right_scalar的单测,是不是实现时没考虑位置不同计算的区别 @luqiang-guo

Copy link
Contributor

Choose a reason for hiding this comment

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

已修复

@guo-ran
Copy link
Contributor Author

guo-ran commented May 1, 2022

ready for review

@guo-ran guo-ran added the op label May 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2022

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

@guo-ran guo-ran changed the title add copy_nd binary softmax primitive unit tests [primitive] add binary tests May 5, 2022
@MARD1NO
Copy link
Contributor

MARD1NO commented May 5, 2022

@luqiang-guo 麻烦看下guoran在PR中提到的onednn相关数据类型过不了Primitive测试的问题

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

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

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

Speed stats:
GPU Name: NVIDIA GeForce GTX 1080 

❌ OneFlow resnet50 time: 129.2ms (= 12918.7ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 147.2ms (= 14723.0ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.14 (= 147.2ms / 129.2ms)

OneFlow resnet50 time: 77.3ms (= 7727.2ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 84.2ms (= 8420.4ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.09 (= 84.2ms / 77.3ms)

OneFlow resnet50 time: 58.0ms (= 11603.0ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 61.1ms (= 12229.4ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.05 (= 61.1ms / 58.0ms)

OneFlow resnet50 time: 40.6ms (= 8122.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 44.0ms (= 8793.9ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.08 (= 44.0ms / 40.6ms)

OneFlow resnet50 time: 35.4ms (= 7072.0ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 37.8ms (= 7565.9ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.07 (= 37.8ms / 35.4ms)

OneFlow swin dataloader time: 0.253s (= 50.691s / 200, num_workers=1)
PyTorch swin dataloader time: 0.153s (= 30.633s / 200, num_workers=1)
Relative speed: 0.604 (= 0.153s / 0.253s)

OneFlow swin dataloader time: 0.067s (= 13.385s / 200, num_workers=4)
PyTorch swin dataloader time: 0.042s (= 8.318s / 200, num_workers=4)
Relative speed: 0.621 (= 0.042s / 0.067s)

OneFlow swin dataloader time: 0.059s (= 11.868s / 200, num_workers=8)
PyTorch swin dataloader time: 0.022s (= 4.397s / 200, num_workers=8)
Relative speed: 0.371 (= 0.022s / 0.059s)

❌ OneFlow resnet50 time: 147.3ms (= 14731.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 169.4ms (= 16941.9ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.15 (= 169.4ms / 147.3ms)

OneFlow resnet50 time: 99.0ms (= 9900.6ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 109.7ms (= 10965.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.11 (= 109.7ms / 99.0ms)

OneFlow resnet50 time: 74.8ms (= 14962.9ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 87.7ms (= 17544.8ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
❌ Relative speed: 1.17 (= 87.7ms / 74.8ms)

OneFlow resnet50 time: 63.1ms (= 12615.1ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 74.5ms (= 14900.1ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.18 (= 74.5ms / 63.1ms)

OneFlow resnet50 time: 55.4ms (= 11079.6ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 69.4ms (= 13876.6ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.25 (= 69.4ms / 55.4ms)

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

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

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

Speed stats:
GPU Name: NVIDIA GeForce GTX 1080 

❌ OneFlow resnet50 time: 131.4ms (= 13141.0ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 148.5ms (= 14851.2ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.13 (= 148.5ms / 131.4ms)

OneFlow resnet50 time: 82.3ms (= 8226.7ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 89.2ms (= 8916.6ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.08 (= 89.2ms / 82.3ms)

OneFlow resnet50 time: 56.2ms (= 11239.1ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 61.0ms (= 12201.8ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.09 (= 61.0ms / 56.2ms)

OneFlow resnet50 time: 44.9ms (= 8971.7ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 48.2ms (= 9635.8ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.07 (= 48.2ms / 44.9ms)

OneFlow resnet50 time: 38.9ms (= 7784.1ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 38.8ms (= 7763.0ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.00 (= 38.8ms / 38.9ms)

OneFlow swin dataloader time: 0.250s (= 50.032s / 200, num_workers=1)
PyTorch swin dataloader time: 0.151s (= 30.162s / 200, num_workers=1)
Relative speed: 0.603 (= 0.151s / 0.250s)

OneFlow swin dataloader time: 0.108s (= 21.510s / 200, num_workers=4)
PyTorch swin dataloader time: 0.041s (= 8.226s / 200, num_workers=4)
Relative speed: 0.382 (= 0.041s / 0.108s)

OneFlow swin dataloader time: 0.063s (= 12.535s / 200, num_workers=8)
PyTorch swin dataloader time: 0.022s (= 4.402s / 200, num_workers=8)
Relative speed: 0.351 (= 0.022s / 0.063s)

❌ OneFlow resnet50 time: 146.6ms (= 14655.6ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 170.7ms (= 17070.1ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.16 (= 170.7ms / 146.6ms)

OneFlow resnet50 time: 97.1ms (= 9705.2ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 112.3ms (= 11234.7ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.16 (= 112.3ms / 97.1ms)

OneFlow resnet50 time: 79.4ms (= 15888.0ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 90.5ms (= 18091.2ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
❌ Relative speed: 1.14 (= 90.5ms / 79.4ms)

OneFlow resnet50 time: 65.1ms (= 13013.8ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 86.2ms (= 17241.0ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.32 (= 86.2ms / 65.1ms)

OneFlow resnet50 time: 55.7ms (= 11136.8ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 77.8ms (= 15557.0ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.40 (= 77.8ms / 55.7ms)

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

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

@mergify mergify bot merged commit 58d0052 into master May 7, 2022
@mergify mergify bot deleted the dev_add_primitive_tests branch May 7, 2022 18:35
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.

None yet

4 participants