diff --git a/src/frontends/tensorflow/src/transformations/switch_merge_resolve.cpp b/src/frontends/tensorflow/src/transformations/switch_merge_resolve.cpp index af03b24519c29d..35c2cd1b7f23e1 100644 --- a/src/frontends/tensorflow/src/transformations/switch_merge_resolve.cpp +++ b/src/frontends/tensorflow/src/transformations/switch_merge_resolve.cpp @@ -15,6 +15,7 @@ #include "openvino/op/if.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/result.hpp" +#include "openvino/op/util/multi_subgraph_base.hpp" #include "tf_utils.hpp" using namespace ov; @@ -151,6 +152,16 @@ void insert_result_before_merge(const shared_ptr& merge_node, } // namespace bool pass::SwitchMergeResolver::run_on_model(const shared_ptr& m) { + // run this transformation recursively since this is a model pass + for (const auto& op : m->get_ordered_ops()) { + auto multisubgraph_op = as_type_ptr(op); + if (multisubgraph_op) { + for (size_t i = 0; i < multisubgraph_op->get_internal_subgraphs_size(); ++i) { + run_on_model(multisubgraph_op->get_function(static_cast(i))); + } + } + } + // split set of Switch and Merge nodes to clusters // where each cluster of Switch and Merge nodes will represent // the single If operation for fusing diff --git a/src/frontends/tensorflow_common/src/helper_transforms/const_to_result_remover.cpp b/src/frontends/tensorflow_common/src/helper_transforms/const_to_result_remover.cpp index 1963bcf47dae22..d16152ca492246 100644 --- a/src/frontends/tensorflow_common/src/helper_transforms/const_to_result_remover.cpp +++ b/src/frontends/tensorflow_common/src/helper_transforms/const_to_result_remover.cpp @@ -16,6 +16,8 @@ namespace tensorflow { namespace pass { bool ConstToResultRemover::run_on_model(const std::shared_ptr& m) { + // Note: need to perform this transformation only on the main ov::Model graph + // no need to apply it for sub-graphs! ResultVector results_to_remove; // look for isolated UnsupportedConst->Result sub-graphs to remove // also, find isolated Constant->Result sub-graphs to remove