CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[PIR] Support for If grad execution of ControlFlow ops #59200
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
Conversation
paddle/fluid/framework/new_executor/instruction/stack_create_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/stack_create_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/stack_create_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/instruction_util.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/instruction_util.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/pir_adaptor/pir_adaptor_util.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.h
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/interpreter/dependency_builder.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/pir_adaptor/pir_adaptor_util.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.h
Show resolved
Hide resolved
@@ -105,6 +106,7 @@ class IR_API HasElementsOp : public Op<HasElementsOp> { | |||
OperationArgument &argument, // NOLINT | |||
Value stack); | |||
void VerifySig(); | |||
Value input() { return operand_source(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.
这个接口和57行的inlet接口好像是重复的。
paddle::framework::InterpreterCore test_core( | ||
place, {}, kernel_program->block(), &scope); | ||
|
||
test_core.Run({}); |
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.
同意,需添加执行结果检查、同时添加 GPU 测试 case
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
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Show resolved
Hide resolved
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.
Great job!
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.h
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/has_elements_instruction.cc
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_pop_instruction.cc
Show resolved
Hide resolved
paddle/fluid/framework/new_executor/instruction/tuple_push_instruction.cc
Show resolved
Hide resolved
@@ -442,14 +500,14 @@ void HandleForSpecialOp(pir::Operation* op, | |||
auto value = op->result(0); | |||
|
|||
value_exe_info->Add(value, param_name); | |||
} else if (op_name == "builtin.constant") { | |||
} else if (op->isa<pir::ConstantOp>()) { |
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.
} else if (op->isa<pir::ConstantOp>()) { | |
} else if (op->isa<pir::ConstantTensorOp>()) { |
分支里只有ConstantTensorOp逻辑,且if判断可以移除
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.
下个pr修改
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.
这里是我修改错误,ConstantTensorOp继承自ConstantOp,应该还用op_name判断,不能用isa判断,下个PR更改
@@ -622,8 +630,22 @@ void PirInterpreter::BuildInstruction() { | |||
continue; | |||
} | |||
} else if (op.dialect()->name() == "cf") { | |||
VLOG(6) << "skip process cf dialect op: " << op.name(); | |||
continue; | |||
if (op.isa<pir::TuplePushOp>()) { |
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.
在函数前面可以借助宏来规范代码接口,比如:
#define CREATE_INSTR(instr_name) \
vec_instruction_base_.emplace_back( \
std::make_unique<instr_name>( \
op_idx++, place_, &op, value_exe_info_.get()));
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.
if-else {} 分支里就可以直接使用:
CREATE_INSTR(TuplePushInstruction);
CREATE_INSTR(TuplePopInstruction);
CREATE_INSTR(HasElementsInstruction);
....
这样大家派生的Instruction 就可以约束成特定的规范,下面的LegacyKernelInstruction就可以规范下value_exe_info_的传参类型了。
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.
下个pr修改
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
Description
Pcard-67164
为控制流OP反向执行相关算子在执行器初始化部分添加相应行为。
执行思路:
stack_create_op、tuple_push_op、tuple_pop_op、has_elements_op 是需要在执行期间执行的四个算子: