-
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
[IR] Add Construct event for new ir interpretercore #55555
[IR] Add Construct event for new ir interpretercore #55555
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… dev/construct_event
… dev/construct_event
… dev/construct_event
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
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
VLOG(6) << "finish process device context"; | ||
|
||
Scope* inner_scope = local_scope == nullptr ? scope : local_scope; | ||
InitInputsOutputsIds( | ||
op, inner_scope, value_2_var_name, var_name_2_id, variable_2_var_name); | ||
VLOG(6) << "finish process inputs outputs index"; | ||
|
||
auto no_need_buffer_ids = yaml_info_parser.NoNeedBufferIds(); |
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.
auto 会隐式触发copy,如果接口返回的是引用,这里建议用auto &
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.
已完善
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.
stream_analyzer的代码基本是重复拷贝了一份,这块目前正在被完善,且在不久的未来可能被重构,值得考虑通过抽象和复用公共逻辑,减少重复代码的数量,否则会给后续多流机制的迭代带来较大的负担。
|
||
std::unordered_map<ir::Value, std::vector<int>> output_index_; | ||
std::unordered_set<::ir::Value> no_need_buffer_; |
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.
std::unordered_set<::ir::Value> no_need_buffer_; | |
std::unordered_set<::ir::Value> no_need_buffer_values_; |
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.
已完善
@@ -32,6 +34,114 @@ | |||
namespace paddle { | |||
namespace framework { | |||
|
|||
using DeviceContext = paddle::platform::DeviceContext; | |||
|
|||
class IrContextManager { |
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.
ContextManager
并不依赖新IR,为何也需要重复一份?
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.
已复用
auto no_need_buffer_ids = yaml_info_parser.NoNeedBufferIds(); | ||
std::unordered_set<::ir::Value> no_need_buffer_values; | ||
for (size_t id = 0; id < no_need_buffer_ids.size(); id++) { | ||
no_need_buffer_values.insert(op->operand(id)); |
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.
no_need_buffer_ids
里的元素一定是从0开始连续递增的吗?
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.
逻辑有问题,已修正
@@ -550,8 +550,7 @@ void DependencyBuilder::ShrinkDownstreamMap() { | |||
/// For new ir /// | |||
/// ======================== /// | |||
const std::map<size_t, std::set<size_t>>& IrDependencyBuilder::Build( | |||
const std::vector<std::unique_ptr<paddle::framework::InstructionBase>>& | |||
instructions) { | |||
const std::vector<paddle::framework::InstructionBase*>& instructions) { |
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.
为什么要把unique_ptr
改成裸指针?
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.
已改回
@@ -173,6 +178,10 @@ bool IsMemcpyH2D(const Instruction& instr) { | |||
return instr.OpBase()->Type() == kMemcpyH2D; | |||
} | |||
|
|||
bool IsMemcpyH2D(const paddle::framework::InstructionBase* instr) { |
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.
InstructionBase
的命名容易被误认为是两套Insturction
的公共基类,但其实现却是针对新IR的,且同文件下又有一个以Instruction
对象作为入参的IsMemcpyH2D
函数,令人困惑。
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.
由于是中间态,最终态下 NewIR 的执行器中,将不会存在 Instruction 的相关信息
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
New features
PR changes
Others
Description
基于新 IR InstructionBase 体系,支持 ConstructEvent 模块。
后续工作:
Others
Pcard-67164