-
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
[PIR] Support while grad exe #59496
[PIR] Support while grad exe #59496
Conversation
…e/Paddle into dev/pir_while_exe
@@ -44,11 +44,13 @@ class HasElementsInstruction : public InstructionBase { | |||
|
|||
std::string name_{"has_elelments_instruction"}; | |||
|
|||
const platform::DeviceContext* dev_ctx_; // not owned | |||
// const platform::DeviceContext* dev_ctx_; // not owned |
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.
已删除
uint64_t num) { | ||
std::stack<const Variable*> rtn; | ||
for (uint64_t i = 0; i < num; i++) { | ||
rtn.push(var_array->at(var_array->size() - 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.
这里每次都要压栈一遍,后续可以优化一下
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.
push var_array的最后一个元素,是不是可以给var_array提供一个back()接口?
/// ... | ||
/// } | ||
/// | ||
class IR_API HasElementsOp : public pir::Op<HasElementsOp> { |
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.
都移到上面了,这个IR_API是不是可以删了?
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 完善~
/// in the While usage scenario. Example: | ||
/// (%stack_0, %inlet_0, %outlet_0) = "cf.create_stack" () | ||
/// ... | ||
/// (%0) = "cf.has_elements" (%stack_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.
pd_op.has_elements
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 完善~
auto var_array = value_exe_info_->GetVarByValue(stack_value); | ||
stack_element_var_array_ = var_array->GetMutable<VariableRefArray>(); | ||
} | ||
|
||
void HasElementsInstruction::Run() { | ||
VLOG(6) << "run has_elements instruction"; | ||
bool is_empty = stack_element_var_array_->size(); |
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.
这个 stack_element_var_array_没有empty接口吗?调用size(),返回bool值感觉有点奇怪
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.
LGTM
IR_ENFORCE(num_results() == 1u, "The size of outputs must be equal to 1."); | ||
IR_ENFORCE((*this)->result_type(0).isa<DenseTensorType>() || | ||
(*this)->result_type(0).isa<AllocatedDenseTensorType>(), | ||
"The type of cf.has_elements' output is not correct."); |
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.
"The type of cf.has_elements' output is not correct."); | |
"The type of pd_op.has_elements' output is not correct."); |
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 fix
PR types
New features
PR changes
Others
Description
支持 while grad 执行
Pcard-67164