[GPU] Fix for reorder fusing in fuse_constant_transposes pass (#20651)

This commit is contained in:
Roman Lyamin 2023-10-24 09:21:30 +04:00 committed by GitHub
parent 894221ea38
commit 59fe0a05a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1221,6 +1221,8 @@ void prepare_primitive_fusing::fuse_constant_transposes(program& p) {
return format::find_format(new_order, fmt.block_sizes());
};
std::vector<std::pair<program_node*, program_node*>> to_replace_nodes;
auto& proc_order = p.get_processing_order();
auto itr = proc_order.begin();
while (itr != proc_order.end()) {
@ -1285,9 +1287,7 @@ void prepare_primitive_fusing::fuse_constant_transposes(program& p) {
auto new_reorder = std::make_shared<reorder>(next_node->id() + "_reorder_fmt", new_const_node.id(), reorder_layout);
auto& new_reorder_node = p.get_or_create(new_reorder);
p.replace(*next_node, new_reorder_node);
new_reorder_node.recalc_output_layout(false);
itr = std::find(proc_order.begin(), proc_order.end(), &new_reorder_node);
to_replace_nodes.emplace_back(std::make_pair(next_node, &new_reorder_node));
} else {
layout reorder_layout = new_const_node.get_output_layout();
reorder_layout.format = format::bfyx;
@ -1299,6 +1299,11 @@ void prepare_primitive_fusing::fuse_constant_transposes(program& p) {
}
}
}
for (auto& nodes : to_replace_nodes) {
p.replace(*nodes.first, *nodes.second);
nodes.second->recalc_output_layout(false);
}
}
void prepare_primitive_fusing::optimize_fused_ops(program& p) {