CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
【Paddle TensorRT】fix PaddleX pir-trt 3 #71287
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
你的PR提交成功,感谢你对开源项目的贡献! |
auto *first_def_op = size_tensor.defining_op(); | ||
bool found_shape_op = false; | ||
auto operand0 = first_def_op->operand_source(0); | ||
auto *second_def_op = operand0.defining_op(); | ||
if (first_def_op && first_def_op->isa<paddle::dialect::ShapeOp>()) { | ||
found_shape_op = true; | ||
} else if ((first_def_op->name().find("builtin.combine") != | ||
std::string::npos) && | ||
(second_def_op->isa<paddle::dialect::DataOp>())) { | ||
found_shape_op = true; | ||
} | ||
if (!found_shape_op && first_def_op && first_def_op->num_operands() > 0) { | ||
if (operand0.impl()) { | ||
if (second_def_op && second_def_op->isa<paddle::dialect::ShapeOp>()) { | ||
found_shape_op = true; | ||
} | ||
} | ||
} |
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.
done
std::vector<std::string> size_tensor_names = desc.Input("SizeTensor"); | ||
for (const auto& tensor_name : size_tensor_names) { | ||
auto* var_desc = block->FindVarRecursive(tensor_name); | ||
if (!var_desc) continue; | ||
if (tensor_name.find("shape") != std::string::npos) { | ||
valid_source = true; | ||
break; | ||
} | ||
} |
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.
done
@@ -57,7 +57,6 @@ DEFINE_GENERAL_PATTERN(Reshape, paddle::dialect::ReshapeOp) | |||
DEFINE_GENERAL_PATTERN(Dropout, paddle::dialect::DropoutOp) | |||
DEFINE_GENERAL_PATTERN(Bmm, paddle::dialect::BmmOp) | |||
DEFINE_GENERAL_PATTERN(Concat, paddle::dialect::ConcatOp) | |||
DEFINE_GENERAL_PATTERN(Nonzero, paddle::dialect::NonzeroOp) |
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.
nonzero的不用删了,我已经完善机制了,可以进trt了
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.
done
@@ -2914,7 +2945,6 @@ class TrtOpMarkerPass : public pir::PatternRewritePass { | |||
ADD_PATTERN(Conv2d) | |||
ADD_PATTERN(FusedConv2dAddAct) | |||
ADD_PATTERN(DepthwiseConv2d) | |||
ADD_PATTERN(Nonzero) |
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.
done
auto *first_def_op = size_tensor.defining_op(); | ||
std::vector<std::string> upstream_op_names; | ||
if (first_def_op) { | ||
upstream_op_names.push_back(first_def_op->name()); | ||
if (first_def_op->num_operands() > 0) { | ||
auto second_input = first_def_op->operand_source(0); | ||
if (second_input.impl()) { | ||
auto *second_def_op = second_input.defining_op(); | ||
if (second_def_op) { | ||
upstream_op_names.push_back(second_def_op->name()); | ||
} | ||
auto third_input = second_def_op->operand_source(0); | ||
if (third_input.impl()) { | ||
auto *third_def_op = third_input.defining_op(); | ||
upstream_op_names.push_back(third_def_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.
这段代码太复杂了,改成这样呢:
auto *first_def_op = size_tensor.defining_op();
std::vector<std::string> upstream_op_names;
upstream_op_names.push_back(first_def_op->name());
if (first_def_op->num_operands() > 0 && first_def_op->operand_source(0).impl()) {
auto second_input = first_def_op->operand_source(0);
auto *second_def_op = second_input.defining_op();
upstream_op_names.push_back(second_def_op->name());
if (second_def_op->num_operands() > 0 && second_def_op->operand_source(0).impl()) {
auto third_input = second_def_op->operand_source(0);
auto *third_def_op = third_input.defining_op();
upstream_op_names.push_back(third_def_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.
可以
* fix trt model bugs * fix bugs * fix inplace bugs * fix * fix * fix * fix * fix slice * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * code-style * fix * fix --------- Co-authored-by: YuanRisheng <yuanrisheng@baidu.com>
PR Category
Inference
PR Types
Bug fixes
Description
Pcard-71500
修复内容:
[02/27/2025-04:08:58] [TRT] [E] 4: [shapeCompiler.cpp::evaluateShapeChecks::1276] Error Code 4: Internal Error (kOPT values for profile 0 violate shape constraints: (Unnamed Layer* 36) [Slice]: ISliceLayer has out of bounds access on axis 1 Condition '<' violated: 501 >= 501.)