-
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
Support feed op new ir #54840
Support feed op new ir #54840
Changes from all commits
f9ecefc
b53e19a
10619e5
c3e3ce0
fa4f213
cf193ef
4419a6c
0c47e47
13bd7a1
794637d
54bd0be
9e4d877
563a5f5
b9e9047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,9 @@ phi::KernelKey GetKernelKey( | |
ir::Operation* op, | ||
const phi::Place& place, | ||
const std::unordered_map<ir::Value, ir::OpResult>& map_value_pair) { | ||
if (op->name() == "pd.feed") { | ||
return {phi::Backend::CPU, phi::DataLayout::ANY, phi::DataType::FLOAT32}; | ||
} | ||
phi::Backend kernel_backend = phi::Backend::UNDEFINED; | ||
phi::DataLayout kernel_layout = phi::DataLayout::UNDEFINED; | ||
phi::DataType kernel_data_type = phi::DataType::UNDEFINED; | ||
|
@@ -110,7 +113,9 @@ phi::KernelKey GetKernelKey( | |
continue; | ||
} | ||
auto input_tmp = op->operand(i).source(); | ||
|
||
auto new_input_tmp = map_value_pair.at(input_tmp); | ||
|
||
auto input_type = new_input_tmp.type(); | ||
dialect::AllocatedDenseTensorType type; | ||
if (input_type.isa<dialect::AllocatedDenseTensorType>()) { | ||
|
@@ -181,32 +186,34 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog) { | |
|
||
std::vector<ir::Type> op_output_types; | ||
if ((*it)->num_results() > 0) { | ||
auto result_type = (*it)->result(0).type(); | ||
if (result_type.isa<dialect::DenseTensorType>()) { | ||
auto allocated_dense_tensor_dtype = | ||
paddle::dialect::AllocatedDenseTensorType::get( | ||
ctx, | ||
phi::TransToPhiPlace(kernel_key.backend()), | ||
result_type.dyn_cast<dialect::DenseTensorType>()); | ||
op_output_types.push_back(allocated_dense_tensor_dtype); | ||
} else if (result_type.isa<ir::VectorType>()) { | ||
auto pos1 = result_type.dyn_cast<ir::VectorType>().data()[0]; | ||
|
||
if (pos1.isa<dialect::DenseTensorType>()) { | ||
for (size_t i = 0; i < (*it)->num_results(); ++i) { | ||
auto result_type = (*it)->result(i).type(); | ||
if (result_type.isa<dialect::DenseTensorType>()) { | ||
auto allocated_dense_tensor_dtype = | ||
paddle::dialect::AllocatedDenseTensorType::get( | ||
ctx, | ||
phi::TransToPhiPlace(kernel_key.backend()), | ||
pos1.dyn_cast<dialect::DenseTensorType>()); | ||
result_type.dyn_cast<dialect::DenseTensorType>()); | ||
op_output_types.push_back(allocated_dense_tensor_dtype); | ||
} else { | ||
PADDLE_THROW(phi::errors::Unimplemented( | ||
"only support dense tensor in vector type for now")); | ||
} else if (result_type.isa<ir::VectorType>()) { | ||
auto pos1 = result_type.dyn_cast<ir::VectorType>().data()[0]; | ||
|
||
if (pos1.isa<dialect::DenseTensorType>()) { | ||
auto allocated_dense_tensor_dtype = | ||
paddle::dialect::AllocatedDenseTensorType::get( | ||
ctx, | ||
phi::TransToPhiPlace(kernel_key.backend()), | ||
pos1.dyn_cast<dialect::DenseTensorType>()); | ||
op_output_types.push_back(allocated_dense_tensor_dtype); | ||
} else { | ||
PADDLE_THROW(phi::errors::Unimplemented( | ||
"only support dense tensor in vector type for now")); | ||
} | ||
|
||
ir::Type t1 = ir::VectorType::get(ctx, op_output_types); | ||
op_output_types.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么要clear op_output_types? op_output_types的每个index对应的不是result_type所在的位置么,这里的clear是放在其中的一个分支里的。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这块确实是一个bug,仅在有一个 VectorType的情况是对的,其他的场景是有bug的,我看看怎么修复 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在 pr #54865 中修复 |
||
op_output_types.push_back(t1); | ||
} | ||
|
||
ir::Type t1 = ir::VectorType::get(ctx, op_output_types); | ||
op_output_types.clear(); | ||
op_output_types.push_back(t1); | ||
} | ||
} | ||
|
||
|
@@ -249,7 +256,9 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog) { | |
|
||
// only deal with single output | ||
if ((*it)->num_results() > 0) { | ||
map_value_pair[(*it)->result(0)] = op1->result(0); | ||
for (size_t i = 0; i < (*it)->num_results(); ++i) { | ||
map_value_pair[(*it)->result(i)] = op1->result(i); | ||
} | ||
} | ||
|
||
program->block()->push_back(op1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,7 @@ | |
out : Out | ||
|
||
- op : atan2 | ||
backward : atan2_grad | ||
inputs : | ||
{x : X1, y : X2} | ||
outputs : | ||
|
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.
这里直接取了[0],是说当result_type为vector时,内在元素至少有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.
这个问题 和下面的问题 是一起的,原来仅支持单个输出, 我升级了多输出,但是这块的逻辑没有适配对