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

Fix bug error msg format #5866

Merged
merged 16 commits into from Aug 17, 2021
Merged

Fix bug error msg format #5866

merged 16 commits into from Aug 17, 2021

Conversation

liufengwei0103
Copy link
Contributor

@liufengwei0103 liufengwei0103 commented Aug 13, 2021

  1. 重写了语义更明显的函数名
  2. 重写了把msg缩短的函数
  3. 加上了在error_type中的msg信息

ss << error->config_resource_unavailable_error().DebugString();
break;
case cfg::ErrorProto::kConfigAssertFailedError:
ss << error->config_assert_failed_error().DebugString();
Copy link
Contributor

Choose a reason for hiding this comment

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

可以看下这个可不可以用反射实现,这样手动列出每一种情况是不可维护的,用反射的话伪代码大概是这样:

ss << PbMessage2Txt(error->getMessage(error->error_type_name()))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

可以看下这个可不可以用反射实现,这样手动列出每一种情况是不可维护的,用反射的话伪代码大概是这样:

ss << PbMessage2Txt(error->getMessage(error->error_type_name()))

已修改采用反射实现

ss << " ... ";
CHECK_OR_RETURN(right_index >= 0);
CHECK_OR_RETURN(right_index < str.size());
ss << str.substr(right_index);
return ss.str();
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是否需要包一层CHECK?

ss << "\n" << FormatErrorSummaryAndMsg(error);
// Get msg from error type of error proto
std::string msg_of_error_type = *JUST(FormatMsgOfErrorType(error));
if (msg_of_error_type.size() != 0) { ss << "\n" << msg_of_error_type; }
return ss.str();
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是否也要check下

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 139.6ms (= 6980.8ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.1ms (= 6405.5ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.09 (= 139.6ms / 128.1ms)

PyTorch resnet50 time: 84.9ms (= 4247.4ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.5ms (= 3724.3ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.14 (= 84.9ms / 74.5ms)

PyTorch resnet50 time: 56.4ms (= 2819.8ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 47.8ms (= 2391.5ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.18 (= 56.4ms / 47.8ms)

PyTorch resnet50 time: 49.5ms (= 2477.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 40.3ms (= 2016.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.23 (= 49.5ms / 40.3ms)

PyTorch resnet50 time: 42.5ms (= 2125.0ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 43.2ms (= 2158.5ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 0.98 (= 42.5ms / 43.2ms)

@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 17, 2021 14:33
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 17, 2021 16:13
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 141.5ms (= 7076.9ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.2ms (= 6408.0ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.10 (= 141.5ms / 128.2ms)

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

PyTorch resnet50 time: 54.9ms (= 2744.4ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 48.2ms (= 2408.9ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.14 (= 54.9ms / 48.2ms)

PyTorch resnet50 time: 48.6ms (= 2429.9ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 39.8ms (= 1988.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.22 (= 48.6ms / 39.8ms)

PyTorch resnet50 time: 45.4ms (= 2270.3ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 36.4ms (= 1818.9ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.25 (= 45.4ms / 36.4ms)

@oneflow-ci-bot oneflow-ci-bot merged commit f0e786d into master Aug 17, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the fix_bug_error_msg_format branch August 17, 2021 20:49
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 17, 2021 20:49
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