Skip to content

Commit 25038a9

Browse files
authored
FuseMOEExperts. Check if all inputs of postponed_constant are constants (#32670)
### Details: - FuseMOEExperts. Check if all inputs of postponed_constant are constants ### Tickets: - *ticket-id*
1 parent 552458d commit 25038a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/common/transformations/src/transformations/common_optimizations/fuse_moe_experts.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "openvino/op/topk.hpp"
4040
#include "openvino/op/transpose.hpp"
4141
#include "openvino/op/unsqueeze.hpp"
42+
#include "openvino/op/util/op_types.hpp"
4243
#include "openvino/op/util/shape_of_base.hpp"
4344
#include "openvino/pass/manager.hpp"
4445
#include "openvino/pass/pattern/matcher.hpp"
@@ -47,6 +48,7 @@
4748
#include "openvino/pass/pattern/op/wrap_type.hpp"
4849
#include "transformations/rt_info/decompression.hpp"
4950
#include "transformations/utils/utils.hpp"
51+
5052
namespace ov {
5153
namespace pass {
5254

@@ -396,7 +398,14 @@ ov::pass::FuseMOEExperts::FuseMOEExperts() : MultiMatcher("FuseMOEExperts") {
396398
}
397399

398400
auto fused = std::make_shared<ov::op::v0::Concat>(inputs, 0);
399-
fused->get_rt_info()["postponed_constant"] = true;
401+
if (std::all_of(inputs.begin(), inputs.end(), [](const auto& input) {
402+
return ov::op::util::is_constant(input.get_node());
403+
})) {
404+
// postponed_constant attribute is needed to perform constant folding on serialization step
405+
fused->get_rt_info()["postponed_constant"] = true;
406+
// disable constant folding here to postpone it to serialization step
407+
ov::pass::disable_constant_folding(fused);
408+
}
400409
if (needs_decompress) {
401410
auto convert = std::make_shared<ov::op::v0::Convert>(fused, target_type);
402411
ov::mark_as_decompression(convert);

0 commit comments

Comments
 (0)