-
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
[Paddle-TRT] add flip op #55688
[Paddle-TRT] add flip op #55688
Conversation
@@ -0,0 +1,83 @@ | |||
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. |
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.
改成2023
@@ -0,0 +1,144 @@ | |||
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. |
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.
改2023
return false; | ||
} | ||
#if !IS_TRT_VERSION_GE(7220) | ||
VLOG(3) << "flip is not supported when TensorRT blow 7.2.2"; |
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.
bellow
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.
已全部修正
|
||
// Get Attrs | ||
std::vector<int> axis = | ||
PADDLE_GET_CONST(std::vector<int>, op_desc.GetAttr("axis")); |
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.
原生op定义中,axis 可以是 int也可以是list(vector),这里看起来只考虑了list 的情况?
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.
原生op通过在python源代码中转成list支持int,convert时候只能拿到vector
@@ -2747,6 +2747,23 @@ struct SimpleOpTypeSetTeller : public Teller { | |||
#endif | |||
} | |||
|
|||
if (op_type == "flip") { | |||
if (!desc.HasAttr("axis")) { |
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.
已删除
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
program_config.ops[i].attrs for i in range(len(program_config.ops)) | ||
] | ||
self.trt_param.max_batch_size = 9 | ||
self.trt_param.workspace_size = 1073741824 |
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.
这个没必要开这么大吧
self.trt_param.precision = paddle_infer.PrecisionType.Half | ||
yield self.create_inference_config(), generate_trt_nodes_num( | ||
attrs, True | ||
), 1e-3 |
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.
这个阈值用默认的,没必要放大
* [Paddle-TRT] add flip op
* [Paddle-TRT] add flip op
PR types
Others
PR changes
Others
Description
Pcard-71501
借助Loop实现了flip算子到TRT的映射,并添加相应单测。
整体的逻辑参考paddle2onnx中的flip -> split + concat的思路,Loop中的IIteratorLayer可以通过指定reverse参数实现split + reverse的效果,ILoopOutputLayer可以实现concat的效果。