-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from xczhai/xc/debug_f16_convert
Xc/debug f16 convert
- Loading branch information
Showing
17 changed files
with
1,491 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/fc_convert_fusion.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "fc_convert_fusion.hpp" | ||
|
||
#include <utils/general_utils.h> | ||
|
||
#include <openvino/core/rt_info.hpp> | ||
#include <openvino/pass/pattern/op/wrap_type.hpp> | ||
#include <transformations/utils/utils.hpp> | ||
|
||
#include "itt.hpp" | ||
#include "transformations/cpu_opset/common/op/fully_connected.hpp" | ||
|
||
namespace ov { | ||
namespace intel_cpu { | ||
|
||
FcConvertFusion::FcConvertFusion() { | ||
MATCHER_SCOPE(FcConvertFusion); | ||
using namespace ov::pass::pattern; | ||
|
||
auto a = any_input(); | ||
auto b = any_input(); | ||
auto fc = wrap_type<ov::intel_cpu::FullyConnectedNode>({a, b}, consumers_count(1)); | ||
auto convert = wrap_type<ov::op::v0::Convert>({fc}, type_matches(ov::element::f32)); | ||
|
||
ov::matcher_pass_callback callback = [=](Matcher& m) { | ||
const auto& pattern_map = m.get_pattern_value_map(); | ||
|
||
const auto& m_a = pattern_map.at(a).get_node_shared_ptr(); | ||
const auto& m_b = pattern_map.at(b).get_node_shared_ptr(); | ||
const auto& m_fc = pattern_map.at(fc).get_node_shared_ptr(); | ||
|
||
const auto& m_convert = pattern_map.at(convert).get_node_shared_ptr(); | ||
auto output_type = m_convert->get_output_element_type(0); | ||
|
||
// auto rank = m_fc->get_output_rank(); | ||
auto rank = m_fc->get_output_partial_shape(0).rank(); | ||
auto new_fc = std::make_shared<ov::intel_cpu::FullyConnectedNode>(m_a, m_b, rank, output_type); | ||
|
||
new_fc->set_friendly_name(m_convert->get_friendly_name()); | ||
copy_runtime_info(m.get_matched_nodes(), new_fc); | ||
replace_node(m_convert, new_fc); | ||
return true; | ||
}; | ||
|
||
auto m = std::make_shared<ov::pass::pattern::Matcher>(convert, matcher_name); | ||
this->register_matcher(m, callback); | ||
} | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
18 changes: 18 additions & 0 deletions
18
src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/fc_convert_fusion.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <openvino/pass/graph_rewrite.hpp> | ||
|
||
namespace ov { | ||
namespace intel_cpu { | ||
class FcConvertFusion : public ov::pass::MatcherPass { | ||
public: | ||
OPENVINO_RTTI("FcConvertFusion", "0"); | ||
FcConvertFusion(); | ||
}; | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.