[FrontEnd] add control flow, basic tensor array support for paddle faster_rcnn model (#10684)
* support control flow, tensor array
* fix clang error
* support ppdet2.3 model
* 1. code clean; 2. more comments inlined.
* fix after clone ov::Model no more in need.
* support dynamic shape; more comments
* only process same rank
* remove unused function
* simplify the loop logic
* fix review comments
* support shape{1} {}
* disable FoldSubgraphEmptyInputs because loop in loop
* fix review comments
* remove scalar{}->shape{1} testcase
* allow re-infer shape when backedge changes input shape
* fix condition shape to {1}
* support output rank is not same or dynamic
* fix refactor error
* apply review comments
* fix win warnings
* remove TransformEliminateConvert
Co-authored-by: jialipen <cecilia.peng@intel.com>
Co-authored-by: Evgenya Stepyreva <evgenya.stepyreva@intel.com>
This commit is contained in:
43 files changed
+2776
-44
No files matched your search
+16
@@ -13,6 +13,13 @@ namespace ov {
|
||||
namespace pass {
|
||||
|
||||
class TRANSFORMATIONS_API FoldSubgraphEmptyInputs;
|
||||
class TRANSFORMATIONS_API DisableFoldSubgraphEmptyInputs;
|
||||
|
||||
TRANSFORMATIONS_API void disable_fold_subgraph_empty_inputs(const std::shared_ptr<Node>& node);
|
||||
|
||||
TRANSFORMATIONS_API void enable_fold_subgraph_empty_inputs(const std::shared_ptr<Node>& node);
|
||||
|
||||
TRANSFORMATIONS_API bool fold_subgraph_empty_inputs_is_disabled(const std::shared_ptr<Node>& node);
|
||||
|
||||
} // namespace pass
|
||||
} // namespace ov
|
||||
@@ -29,3 +36,12 @@ public:
|
||||
OPENVINO_RTTI("FoldSubgraphEmptyInputs", "0");
|
||||
FoldSubgraphEmptyInputs();
|
||||
};
|
||||
|
||||
class ov::pass::DisableFoldSubgraphEmptyInputs : public ov::RuntimeAttribute {
|
||||
public:
|
||||
OPENVINO_RTTI("DisableFoldSubgraphEmptyInputs");
|
||||
DisableFoldSubgraphEmptyInputs() = default;
|
||||
bool is_copyable() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
+21
-5
@@ -12,10 +12,8 @@
|
||||
namespace ov {
|
||||
namespace pass {
|
||||
|
||||
class TRANSFORMATIONS_API RemoveConcatZeroDimInput;
|
||||
|
||||
} // namespace pass
|
||||
} // namespace ov
|
||||
class OPENVINO_API RemoveConcatZeroDimInput;
|
||||
class OPENVINO_API DisableRemoveConcatZeroDimInput;
|
||||
|
||||
/**
|
||||
* @ingroup ie_transformation_common_api
|
||||
@@ -23,8 +21,26 @@ class TRANSFORMATIONS_API RemoveConcatZeroDimInput;
|
||||
* removes input of Concat if the tensor size is equal to 0
|
||||
*/
|
||||
|
||||
class ov::pass::RemoveConcatZeroDimInput : public ov::pass::MatcherPass {
|
||||
class RemoveConcatZeroDimInput : public ov::pass::MatcherPass {
|
||||
public:
|
||||
OPENVINO_RTTI("RemoveConcatZeroDimInput", "0");
|
||||
RemoveConcatZeroDimInput();
|
||||
};
|
||||
|
||||
OPENVINO_API void disable_remove_concat_zerodim_input(const std::shared_ptr<Node>& node);
|
||||
|
||||
OPENVINO_API void enable_remove_concat_zerodim_input(const std::shared_ptr<Node>& node);
|
||||
|
||||
OPENVINO_API bool remove_concat_zerodim_input_is_disabled(const std::shared_ptr<Node>& node);
|
||||
|
||||
class DisableRemoveConcatZeroDimInput : public ov::RuntimeAttribute {
|
||||
public:
|
||||
OPENVINO_RTTI("DisableRemoveConcatZeroDimInput");
|
||||
DisableRemoveConcatZeroDimInput() = default;
|
||||
bool is_copyable() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace pass
|
||||
} // namespace ov
|
||||
+17
@@ -22,6 +22,10 @@ ov::pass::FoldSubgraphEmptyInputs::FoldSubgraphEmptyInputs() {
|
||||
if (multi_subgraph_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const auto& rt_info = multi_subgraph_op->get_rt_info();
|
||||
if (rt_info.count(DisableFoldSubgraphEmptyInputs::get_type_info_static())) {
|
||||
return false;
|
||||
}
|
||||
auto multi_subgraph_op_inputs = multi_subgraph_op->input_values();
|
||||
|
||||
std::vector<ov::Output<ov::Node>> empty_inputs;
|
||||
@@ -60,3 +64,16 @@ ov::pass::FoldSubgraphEmptyInputs::FoldSubgraphEmptyInputs() {
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(multi_subgraph_op_pattern, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
void ov::pass::disable_fold_subgraph_empty_inputs(const std::shared_ptr<ov::Node>& node) {
|
||||
node->get_rt_info().emplace(DisableFoldSubgraphEmptyInputs::get_type_info_static(),
|
||||
DisableFoldSubgraphEmptyInputs{});
|
||||
}
|
||||
|
||||
void ov::pass::enable_fold_subgraph_empty_inputs(const std::shared_ptr<ov::Node>& node) {
|
||||
node->get_rt_info().erase(DisableFoldSubgraphEmptyInputs::get_type_info_static());
|
||||
}
|
||||
|
||||
bool ov::pass::fold_subgraph_empty_inputs_is_disabled(const std::shared_ptr<ov::Node>& node) {
|
||||
return node->get_rt_info().count(DisableFoldSubgraphEmptyInputs::get_type_info_static());
|
||||
}
|
||||
+18
@@ -19,6 +19,11 @@ ov::pass::RemoveConcatZeroDimInput::RemoveConcatZeroDimInput() {
|
||||
auto concat_pattern = pattern::wrap_type<opset8::Concat>();
|
||||
ngraph::matcher_pass_callback callback = [=](pattern::Matcher& m) {
|
||||
auto concat = m.get_match_root();
|
||||
const auto& rt_info = concat->get_rt_info();
|
||||
if (rt_info.count(DisableRemoveConcatZeroDimInput::get_type_info_static())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto concat_inputs = concat->input_values();
|
||||
concat_inputs.erase(
|
||||
std::remove_if(
|
||||
@@ -47,3 +52,16 @@ ov::pass::RemoveConcatZeroDimInput::RemoveConcatZeroDimInput() {
|
||||
auto m = std::make_shared<ngraph::pattern::Matcher>(concat_pattern, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
|
||||
void ov::pass::disable_remove_concat_zerodim_input(const std::shared_ptr<Node>& node) {
|
||||
node->get_rt_info().emplace(DisableRemoveConcatZeroDimInput::get_type_info_static(),
|
||||
DisableRemoveConcatZeroDimInput{});
|
||||
}
|
||||
|
||||
void ov::pass::enable_remove_concat_zerodim_input(const std::shared_ptr<Node>& node) {
|
||||
node->get_rt_info().erase(DisableRemoveConcatZeroDimInput::get_type_info_static());
|
||||
}
|
||||
|
||||
bool ov::pass::remove_concat_zerodim_input_is_disabled(const std::shared_ptr<Node>& node) {
|
||||
return node->get_rt_info().count(DisableRemoveConcatZeroDimInput::get_type_info_static());
|
||||
}
|
||||
@@ -37,7 +37,9 @@ bool ngraph::pass::UnrollIf::run_on_model(const std::shared_ptr<ngraph::Function
|
||||
for (const auto& input_descr : input_descriptions) {
|
||||
auto in_data = if_node->input_value(input_descr->m_input_index);
|
||||
auto& param = body->get_parameters()[input_descr->m_body_parameter_index];
|
||||
ngraph::replace_node(param, {in_data});
|
||||
for (const auto& input : param->output(0).get_target_inputs()) {
|
||||
input.replace_source_output(in_data);
|
||||
}
|
||||
}
|
||||
for (const auto& output_desc : output_descriptions) {
|
||||
std::shared_ptr<opset8::Result> result = body->get_results()[output_desc->m_body_value_index];
|
||||
|
||||
Reference in new issue
Block a user