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

refactor_symbol #5941

Merged
merged 7 commits into from
Aug 18, 2021
Merged

refactor_symbol #5941

merged 7 commits into from
Aug 18, 2021

Conversation

clackhan
Copy link
Contributor

No description provided.

@@ -39,7 +39,7 @@ class Symbol final {
Symbol(Symbol&& rhs) = default;
~Symbol() = default;

operator bool() const { return ptr_ != nullptr; }
explicit operator bool() const { return ptr_ != nullptr; }
Copy link
Contributor

Choose a reason for hiding this comment

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

explicit 是不是只有在一个参数的时候才有意义?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

explicit 是不是只有在一个参数的时候才有意义?

此处explicit的作用防止Symbol在某些非预期的地方隐士转换为bool值导致在编译时放过某些错误,例如下面代码编译器认为是正确的:

  Symbol<DType> dtype = JUST(DType::Get(DataType::kFloat));
  DataType data_type = DataType::kFloat;
  Symbol<cfg::SbpParallel> sbp = JUST(MakeBroadcastSbpParallel());
  if (data_type == dtype) {
    // do nothing
  }
  if (data_type == sbp) {
    // do nothing
  }

@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 18, 2021 09:54
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 18, 2021 10:17
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 18, 2021 11:29
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 18, 2021 12:30
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 18, 2021 14:01
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 142.3ms (= 7116.2ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.3ms (= 6416.0ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.11 (= 142.3ms / 128.3ms)

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

PyTorch resnet50 time: 57.1ms (= 2857.5ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 48.5ms (= 2422.7ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.18 (= 57.1ms / 48.5ms)

PyTorch resnet50 time: 52.1ms (= 2605.8ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 38.7ms (= 1935.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.35 (= 52.1ms / 38.7ms)

PyTorch resnet50 time: 43.9ms (= 2197.3ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 40.8ms (= 2039.7ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.08 (= 43.9ms / 40.8ms)

@oneflow-ci-bot oneflow-ci-bot merged commit 9681fa8 into master Aug 18, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the refactor_symbol branch August 18, 2021 15:24
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