未验证 提交 1448520d 编写于 作者: S shentanyue 提交者: GitHub

[TensorRT] Fix delete fill_constant pass (#43053)

* update lite compile cmake

* Update delete_fill_constant_op_pass.cc

* Update analysis_config.cc
上级 ed2886de
......@@ -30,13 +30,19 @@ void FillConstData(LoDTensor* out_t, T value) {
void DeleteFillConstantOpPass::ApplyImpl(ir::Graph* graph) const {
FusePassBase::Init("delete_fill_constant_op_pass", graph);
GraphPatternDetector detector;
auto fill_constant_op = detector.mutable_pattern()
->NewNode("fill_constant")
->assert_is_op("fill_constant")
->assert_is_not_op_input("ValueTensor")
->assert_is_not_op_input("str_value")
->assert_is_not_op_input("ShapeTensor")
->assert_is_not_op_input("ShapeTensorList");
auto fill_constant_op =
detector.mutable_pattern()
->NewNode("fill_constant")
->assert_is_op("fill_constant")
->assert_is_not_op_input("ValueTensor")
->assert_is_not_op_input("str_value")
->assert_is_not_op_input("ShapeTensor")
->assert_is_not_op_input("ShapeTensorList")
->assert_more([&](Node* node) {
return node->Op()
->GetAttrIfExists<std::vector<int64_t>>("shape")
.size() == 1;
});
auto fill_constant_out =
detector.mutable_pattern()
->NewNode("fill_constant_out")
......
......@@ -273,6 +273,11 @@ std::unique_ptr<Graph> IRPassManager::Apply(std::unique_ptr<Graph> graph) {
if (pass->Type() != "graph_viz_pass" && !disable_logs_) {
PrettyLogEndl(Style::H2(), "--- Running IR pass [%s]", pass->Type());
}
// delete_fill_constant_op_pass is not apply under trt dynamic shape
if (pass->Type() == "delete_fill_constant_op_pass") {
bool use_dynamic = pass->Get<bool>("with_dynamic_shape");
if (use_dynamic) continue;
}
graph.reset(pass->Apply(graph.release()));
}
return graph;
......
......@@ -633,11 +633,6 @@ void AnalysisConfig::Update() {
(pass == "conv_bn_fuse_pass")) {
continue;
}
// delete_fill_constant_op_pass is not used under trt dynamic shape
if ((!min_input_shape_.empty() || trt_tuned_dynamic_shape_) &&
pass == "delete_fill_constant_op_pass") {
continue;
}
pass_builder()->AppendPass(pass);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册