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 scalar op #5778

Merged
merged 98 commits into from Aug 15, 2021
Merged

Dev scalar op #5778

merged 98 commits into from Aug 15, 2021

Conversation

MARD1NO
Copy link
Contributor

@MARD1NO MARD1NO commented Aug 7, 2021

增加logical scalar系列op

并去除原始实现中不必要的Tensor构造

@MARD1NO MARD1NO requested a review from Ldpe2G August 7, 2021 06:22
oneflow/core/functional/functional_api.yaml Outdated Show resolved Hide resolved
oneflow/user/ops/scalar_logical_op.cpp Outdated Show resolved Hide resolved
oneflow/user/kernels/scalar_logical_kernels.cpp Outdated Show resolved Hide resolved
oneflow/user/kernels/scalar_logical_kernels.h Outdated Show resolved Hide resolved
oneflow/user/kernels/scalar_logical_kernels.h Outdated Show resolved Hide resolved
oneflow/user/kernels/scalar_logical_kernels.h Outdated Show resolved Hide resolved
.SetIsMatchedHob( \
(user_op::HobDeviceTag() == device) \
& (user_op::HobDataType("in", 0) == GetDataType<input_dtype>::value));

Copy link
Contributor

Choose a reason for hiding this comment

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

下面这些宏,还可以再合并一下,参考

#define MATH_BINARY_BROADCAST_LOGICAL_FUNC_SEQ \

#define REGISTER_MATH_BINARY_BROADCAST_LOGICAL_KERNEL(math_type_pair, device, data_type_pair) \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我觉得用这些宏,观感太不清晰了。

Copy link
Contributor

@hjchen2 hjchen2 left a comment

Choose a reason for hiding this comment

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

后向算子也要支持一下

oneflow/user/kernels/scalar_logical_kernels.h Outdated Show resolved Hide resolved
@MARD1NO
Copy link
Contributor Author

MARD1NO commented Aug 8, 2021

后向算子也要支持一下

logical算子我们和pytorch都没有后向

@github-actions
Copy link
Contributor

CI failed, removing label automerge

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 15, 2021 00:31
@MARD1NO MARD1NO requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 15, 2021 01:17
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 15, 2021 01:50
@github-actions
Copy link
Contributor

CI failed, removing label automerge

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 15, 2021 02:30
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 15, 2021 03:13
@MARD1NO MARD1NO requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 15, 2021 03:13
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 140.6ms (= 7029.9ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.1ms (= 6404.7ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.10 (= 140.6ms / 128.1ms)

PyTorch resnet50 time: 84.1ms (= 4206.4ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.6ms (= 3727.6ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.13 (= 84.1ms / 74.6ms)

PyTorch resnet50 time: 58.1ms (= 2906.2ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 48.2ms (= 2411.5ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.21 (= 58.1ms / 48.2ms)

PyTorch resnet50 time: 49.5ms (= 2472.8ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 42.3ms (= 2117.3ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.17 (= 49.5ms / 42.3ms)

PyTorch resnet50 time: 45.4ms (= 2271.1ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 42.4ms (= 2121.8ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.07 (= 45.4ms / 42.4ms)

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 138.1ms (= 6904.0ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.1ms (= 6405.6ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.08 (= 138.1ms / 128.1ms)

PyTorch resnet50 time: 84.5ms (= 4224.9ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.5ms (= 3726.0ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.13 (= 84.5ms / 74.5ms)

PyTorch resnet50 time: 56.6ms (= 2829.1ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 47.6ms (= 2380.7ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.19 (= 56.6ms / 47.6ms)

PyTorch resnet50 time: 47.6ms (= 2382.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 39.8ms (= 1987.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.20 (= 47.6ms / 39.8ms)

PyTorch resnet50 time: 44.4ms (= 2218.3ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 37.9ms (= 1894.0ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.17 (= 44.4ms / 37.9ms)

@oneflow-ci-bot oneflow-ci-bot merged commit b2005c8 into master Aug 15, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the dev_scalar_op branch August 15, 2021 04:40
test_case.assertEqual(m.training, True)
m.eval()
test_case.assertEqual(m.training, False)
# def test_nested_module(test_case):
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么要都注释掉呢?

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

7 participants