-
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 branch 'master' into ywang2/fix_issue_of_memory_cost_so_much_wi…
…th_specify_device_candidate_list
- Loading branch information
Showing
89 changed files
with
2,524 additions
and
232 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
<link rel="stylesheet" href="{{ pathto('_static/css/viewer.min.css', 1) }}" type="text/css" /> | ||
<link rel="stylesheet" href="{{ pathto('_static/css/custom.css', 1) }}" type="text/css" /> | ||
<link rel="stylesheet" href="{{ pathto('_static/css/banner.css', 1) }}" type="text/css" /> | ||
<link rel="stylesheet" href="{{ pathto('_static/css/openVinoDataTables.css', 1) }}" type="text/css" /> | ||
<link href="https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.8/b-3.0.2/b-colvis-3.0.2/b-print-3.0.2/datatables.min.css" rel="stylesheet"> | ||
<link rel="stylesheet" href="{{ pathto('_static/css/coveo_custom.css', 1) }}" type="text/css" /> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script> | ||
|
32 changes: 32 additions & 0 deletions
32
...mon/transformations/include/transformations/op_conversions/fake_convert_decomposition.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,32 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "openvino/pass/matcher_pass.hpp" | ||
#include "transformations_visibility.hpp" | ||
|
||
namespace ov { | ||
namespace pass { | ||
|
||
class TRANSFORMATIONS_API FakeConvertDecomposition; | ||
|
||
} // namespace pass | ||
} // namespace ov | ||
|
||
/** | ||
* @ingroup ov_transformation_common_api | ||
* @brief FakeConvertDecomposition transformation decomposes FakeConvert layer. | ||
* f8: f8e4m3, f8e5m2 | ||
* downconvert: f32->f8, f16->f8, bf16->f8 | ||
* upconvert: f8->f32, f8->f16, f8->bf16 | ||
* output = (upconvert(downconvert(input * scale - shift)) + shift) / scale | ||
* | ||
*/ | ||
|
||
class ov::pass::FakeConvertDecomposition : public ov::pass::MatcherPass { | ||
public: | ||
OPENVINO_MATCHER_PASS_RTTI("FakeConvertDecomposition"); | ||
FakeConvertDecomposition(); | ||
}; |
76 changes: 76 additions & 0 deletions
76
src/common/transformations/src/transformations/op_conversions/fake_convert_decomposition.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,76 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "transformations/op_conversions/fake_convert_decomposition.hpp" | ||
|
||
#include "itt.hpp" | ||
#include "openvino/core/rt_info.hpp" | ||
#include "openvino/op/add.hpp" | ||
#include "openvino/op/constant.hpp" | ||
#include "openvino/op/convert.hpp" | ||
#include "openvino/op/divide.hpp" | ||
#include "openvino/op/fake_convert.hpp" | ||
#include "openvino/op/multiply.hpp" | ||
#include "openvino/op/subtract.hpp" | ||
#include "openvino/pass/pattern/op/wrap_type.hpp" | ||
|
||
ov::pass::FakeConvertDecomposition::FakeConvertDecomposition() { | ||
MATCHER_SCOPE(FakeConvertDecomposition); | ||
auto data = pattern::any_input(); | ||
|
||
auto fake_convert = ov::pass::pattern::wrap_type<ov::op::v13::FakeConvert>(); | ||
|
||
matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) { | ||
auto& pattern_to_output = m.get_pattern_value_map(); | ||
const auto fake_convert_node = | ||
ov::as_type_ptr<ov::op::v13::FakeConvert>(pattern_to_output.at(fake_convert).get_node_shared_ptr()); | ||
|
||
if (fake_convert_node == nullptr || transformation_callback(fake_convert_node)) { | ||
return false; | ||
} | ||
|
||
Output<Node> data{fake_convert_node->input_value(0)}; | ||
const Output<Node> input_scale{fake_convert_node->input_value(1)}; | ||
auto input_type = data.get_element_type(); | ||
|
||
ov::pass::NodeRegistry decomp_ops; | ||
if (input_type != input_scale.get_element_type()) { | ||
input_type = input_scale.get_element_type(); | ||
data = std::make_shared<ov::op::v0::Convert>(data, input_type); | ||
data = decomp_ops.add(data.get_node_shared_ptr()); | ||
} | ||
|
||
std::shared_ptr<Node> result; | ||
const auto scale = decomp_ops.make<ov::op::v1::Multiply>(data, input_scale); | ||
if (fake_convert_node->get_input_size() == 2) { | ||
const auto downconvert = | ||
decomp_ops.make<ov::op::v0::Convert>(scale, fake_convert_node->get_destination_element_type()); | ||
const auto upconvert = decomp_ops.make<ov::op::v0::Convert>(downconvert, input_type); | ||
|
||
result = decomp_ops.make<ov::op::v1::Divide>(upconvert, input_scale); | ||
} else { | ||
const Output<Node> input_shift{fake_convert_node->input_value(2)}; | ||
const auto shift = decomp_ops.make<ov::op::v1::Subtract>(scale, input_shift); | ||
|
||
const auto downconvert = | ||
decomp_ops.make<ov::op::v0::Convert>(shift, fake_convert_node->get_destination_element_type()); | ||
const auto upconvert = decomp_ops.make<ov::op::v0::Convert>(downconvert, input_type); | ||
|
||
const auto deshift = decomp_ops.make<ov::op::v1::Add>(upconvert, input_shift); | ||
result = decomp_ops.make<ov::op::v1::Divide>(deshift, input_scale); | ||
} | ||
|
||
if (result->get_output_element_type(0) != fake_convert_node->get_output_element_type(0)) { | ||
result = decomp_ops.make<ov::op::v0::Convert>(result, fake_convert_node->get_output_element_type(0)); | ||
} | ||
|
||
result->set_friendly_name(m.get_match_root()->get_friendly_name()); | ||
ov::copy_runtime_info(fake_convert_node, decomp_ops.get()); | ||
ov::replace_node(m.get_match_root(), result); | ||
return true; | ||
}; | ||
|
||
auto m = std::make_shared<ov::pass::pattern::Matcher>(fake_convert, matcher_name); | ||
register_matcher(m, callback); | ||
} |
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.