-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
fix RecordEvent interface #39675
Conversation
Thanks for your contribution! |
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default level低一点
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把默认level 4定义一个const常量,这样用户需要设置后面的默认参数而不想改level时可以用这个
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改接口会导致部分使用EventRole的case无法编译,需要修改这些
…_record_event_interface
paddle/fluid/framework/operator.cc
Outdated
@@ -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); |
There was a problem hiding this comment.
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()
否则性能会差
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string类型会导致memcpy,尽量用const char*
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换行有点怪,换成type单独一行吧
…_record_event_interface
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种尽量避免,新执行器只需要记录compute,无需op name,老执行器可以保持和原来一致
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
Others
Describe
往RecordEvent中多加入一个参数,服务于新的Profiler使用。