Skip to content

Commit a737b06

Browse files
committed
Apply suggestions from code review
1 parent 09066aa commit a737b06

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/common/transformations/include/transformations/utils/utils.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ TRANSFORMATIONS_API bool can_eliminate_eltwise_node(const std::shared_ptr<Node>&
280280

281281
TRANSFORMATIONS_API bool is_constant_and_all_values_equal_int(const Output<Node>& output, const int64_t& v);
282282

283-
TRANSFORMATIONS_API bool is_on_constant_path(const ov::Output<ov::Node>& output,
284-
const std::unordered_set<std::type_index>& break_node_types = {});
283+
TRANSFORMATIONS_API bool is_on_constant_path(const ov::Output<ov::Node>& output);
285284

286285
TRANSFORMATIONS_API bool process_subgraph(ov::pass::ModelPass& model_pass, const std::shared_ptr<Node>& node);
287286

src/common/transformations/src/transformations/utils/utils.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "openvino/op/multiply.hpp"
2121
#include "openvino/op/paged_attention.hpp"
2222
#include "openvino/op/parameter.hpp"
23+
#include "openvino/op/random_uniform.hpp"
2324
#include "openvino/op/read_value.hpp"
2425
#include "openvino/op/relu.hpp"
2526
#include "openvino/op/reshape.hpp"
@@ -489,21 +490,21 @@ bool is_constant_and_all_values_equal_int(const Output<Node>& output, const int6
489490
return false;
490491
}
491492

492-
bool is_on_constant_path(const ov::Output<ov::Node>& output,
493-
const std::unordered_set<std::type_index>& break_node_types) {
493+
bool is_on_constant_path(const ov::Output<ov::Node>& output) {
494494
auto status = true;
495-
std::deque<ov::Node*> nodes_to_calculate = {output.get_node()};
495+
496+
auto root_node = output.get_node();
497+
if (!root_node || root_node->get_output_size() == 0) {
498+
return false;
499+
}
500+
std::deque<ov::Node*> nodes_to_calculate = {root_node};
496501

497502
while (status && !nodes_to_calculate.empty()) {
498503
auto current_node = nodes_to_calculate.front();
499504
nodes_to_calculate.pop_front();
500-
501-
// Check if the current node matches any type in break_node_types
502-
if (!break_node_types.empty()) {
503-
std::type_index current_type(typeid(*current_node));
504-
if (break_node_types.find(current_type) != break_node_types.end()) {
505-
return false;
506-
}
505+
// RandomUniform output changes during runtime, so we should not consider it as a constant
506+
if (current_node->get_type_info() == ov::op::v8::RandomUniform::get_type_info_static()) {
507+
return false;
507508
}
508509

509510
if (current_node->get_input_size() == 0 && !ov::is_type<ov::op::v0::Constant>(current_node)) {

src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "openvino/core/type/element_type.hpp"
1111
#include "openvino/op/convert.hpp"
1212
#include "openvino/op/matmul.hpp"
13-
#include "openvino/op/random_uniform.hpp"
1413
#include "openvino/op/transpose.hpp"
1514
#include "openvino/pass/pattern/op/wrap_type.hpp"
1615
#include "ov_ops/fully_connected.hpp"
@@ -20,7 +19,7 @@ ov::intel_cpu::ConvertMatMulToFC::ConvertMatMulToFC() {
2019
MATCHER_SCOPE(ConvertMatMulToFC);
2120
auto activations_m = ov::pass::pattern::any_input(ov::pass::pattern::has_static_rank());
2221
auto weights_path = [](const ov::Output<ov::Node>& output) {
23-
return ov::op::util::is_on_constant_path(output, {typeid(ov::op::v8::RandomUniform)});
22+
return ov::op::util::is_on_constant_path(output);
2423
};
2524
auto weights_m = ov::pass::pattern::any_input(weights_path);
2625
auto matmul_m = ov::pass::pattern::wrap_type<ov::op::v0::MatMul>({activations_m, weights_m},

0 commit comments

Comments
 (0)