-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 trt engine auto build in runtime for dynamic shape #52162
Support trt engine auto build in runtime for dynamic shape #52162
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
bc88932
to
bd58a23
Compare
@@ -199,7 +199,7 @@ void IRPassManager::CreatePasses(Argument *argument, | |||
optim_cache_dir)); | |||
} | |||
pass->Set("model_opt_cache_dir", new std::string(optim_cache_dir)); | |||
} else if (use_static_engine || enable_int8) { | |||
} else { |
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.
去掉这两个判断条件的原因?
&min_shape_tensor, | ||
&max_shape_tensor, | ||
&opt_shape_tensor); | ||
if (shape_range_info_path != "") { |
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.
string.empty()?
&max_shape_tensor, | ||
&opt_shape_tensor); | ||
} else { | ||
int fd = |
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.
文件打开读写这一块c++有封装好的api吧,用c?
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.
void EnableTunedTensorRtDynamicShape(const std::string& shape_range_info_path, | ||
bool allow_build_at_runtime = true); | ||
void EnableTunedTensorRtDynamicShape( | ||
const std::string shape_range_info_path = "", |
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.
有引用不能给默认值?
@@ -441,6 +441,9 @@ class TensorRTEngine { | |||
void SetUseDLA(bool use_dla) { use_dla_ = use_dla; } | |||
void SetDLACore(int dla_core) { dla_core_ = dla_core; } | |||
void SetWithErnie(bool with_ernie) { with_ernie_ = with_ernie; } | |||
void SetWithDynamicShape(bool with_dynamic_shape) { |
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.
新增了这个接口,第250行附近的逻辑可以给删了
@@ -1434,7 +1434,7 @@ bool AnalysisConfig::shape_range_info_collected() const { | |||
} | |||
|
|||
void AnalysisConfig::EnableTunedTensorRtDynamicShape( | |||
const std::string &shape_range_info_path, bool allow_build_at_runtime) { |
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.
保留&
@@ -14,6 +14,7 @@ | |||
// limitations under the License. | |||
|
|||
#include "paddle/fluid/inference/analysis/ir_passes/tensorrt_subgraph_pass.h" | |||
#include <fcntl.h> |
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.
这个头文件有啥用吗?
@@ -224,6 +224,7 @@ class TensorRTEngine { | |||
AnalysisConfig::Precision precision = AnalysisConfig::Precision::kFloat32, | |||
TRTInt8Calibrator* calibrator = nullptr, | |||
int device_id = 0, | |||
bool with_dynamic_shape = false, |
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.
为什么要加上这一个选项呢?
以前是根据啥来区分是动态shape还是静态shape呢?
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
|
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
Describe
添加配置Paddle-Trt动态Shape的新方式:
两个可改进的点: