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 RecordEvent interface #39675

Merged
merged 7 commits into from
Feb 19, 2022

Conversation

rainyfly
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

往RecordEvent中多加入一个参数,服务于新的Profiler使用。

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

RecordEvent::RecordEvent(const std::string &name, const EventRole role,
uint32_t level) {
RecordEvent::RecordEvent(const std::string &name, const TracerEventType type,
uint32_t level, const EventRole role) {
Copy link
Contributor

Choose a reason for hiding this comment

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

default level低一点

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 RecordEvent(
const std::string& name,
const TracerEventType type = TracerEventType::UserDefined,
uint32_t level = 4, const EventRole role = EventRole::kOrdinary);
Copy link
Contributor

Choose a reason for hiding this comment

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

把默认level 4定义一个const常量,这样用户需要设置后面的默认参数而不想改level时可以用这个

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 RecordEvent(const std::string& name,
const EventRole role = EventRole::kOrdinary,
uint32_t level = 1);
explicit RecordEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

修改接口会导致部分使用EventRole的case无法编译,需要修改这些

@rainyfly rainyfly closed this Feb 17, 2022
@rainyfly rainyfly reopened this Feb 17, 2022
@@ -261,10 +262,12 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) {
// TODO(wangchaochaohu) : refine code to use only one RecordEvent)
// in order to record different op type cost time
// and different op name cost time,we set two event.
platform::RecordEvent op_type_record_event(Type());
platform::RecordEvent op_type_record_event(
Type(), platform::TracerEventType::Operator, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

const std::string& Type() const { return type_; }
写成Type().c_str()
否则性能会差

Copy link
Contributor

Choose a reason for hiding this comment

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

string类型会导致memcpy,尽量用const char*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已改

const EventRole role = EventRole::kOrdinary,
uint32_t level = 1);
explicit RecordEvent(const char* name, const TracerEventType type =
TracerEventType::UserDefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

换行有点怪,换成type单独一行吧

DygraphInferShapeContext<VarType> infer_shape_ctx(
&ins, &outs, &attrs, &default_attrs, op.Type(), &kernel_type);
op.Info().infer_shape_(&infer_shape_ctx);
}

{
platform::RecordEvent record_event(op.Type() + " compute",
platform::EventRole::kInnerOp);
platform::RecordEvent record_event(op.Type() + "::compute",
Copy link
Contributor

Choose a reason for hiding this comment

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

这种尽量避免,新执行器只需要记录compute,无需op name,老执行器可以保持和原来一致

Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit 019a552 into PaddlePaddle:develop Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants