forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CPU] [ARM] FullyConnected: int8 support
- Loading branch information
Showing
100 changed files
with
756 additions
and
53 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...common/low_precision_transformations/include/low_precision/markup_dequantization_fuse.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 "low_precision/lpt_visibility.hpp" | ||
#include <memory> | ||
#include "openvino/pass/graph_rewrite.hpp" | ||
#include "openvino/pass/pattern/matcher.hpp" | ||
|
||
namespace ov { | ||
namespace pass { | ||
namespace low_precision { | ||
|
||
/** | ||
* @ingroup ov_transformation_common_api | ||
* @brief MarkupDequantizationFuse transformation marks not updatable dequantization operations for fusing. | ||
* | ||
* For more details about the transformation, refer to | ||
* [MarkupBias](@ref openvino_docs_OV_UG_lpt_MarkupBias) page | ||
* in the OpenVINO Developer Guide. | ||
*/ | ||
class LP_TRANSFORMATIONS_API MarkupDequantizationFuse : public ov::pass::MatcherPass { | ||
public: | ||
OPENVINO_RTTI("MarkupBias", "0"); | ||
MarkupDequantizationFuse(); | ||
}; | ||
|
||
} // namespace low_precision | ||
} // namespace pass | ||
} // 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
38 changes: 38 additions & 0 deletions
38
src/common/low_precision_transformations/src/markup_dequantization_fuse.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,38 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "low_precision/markup_dequantization_fuse.hpp" | ||
|
||
#include <memory> | ||
#include "openvino/opsets/opset1.hpp" | ||
#include "openvino/pass/pattern/op/wrap_type.hpp" | ||
|
||
#include "itt.hpp" | ||
#include "low_precision/rt_info/bias_attribute.hpp" | ||
|
||
using namespace ov::pass::low_precision; | ||
|
||
MarkupDequantizationFuse::MarkupDequantizationFuse() { | ||
MATCHER_SCOPE(MarkupBias); | ||
auto layer_m = ov::pass::pattern::wrap_type<ov::opset1::MatMul>(ov::pass::pattern::has_static_rank()); | ||
// TODO: getDequantization? | ||
auto bias_const_m = ov::pass::pattern::wrap_type<ov::opset1::Constant>(); | ||
auto bias_m = ov::pass::pattern::wrap_type<ov::opset1::Multiply>({layer_m, bias_const_m}); | ||
|
||
ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { | ||
const auto& pattern_map = m.get_pattern_value_map(); | ||
const auto& const_shape = pattern_map.at(bias_const_m).get_shape(); | ||
|
||
const bool per_channel = std::count_if(const_shape.begin(), const_shape.end(), [](size_t x) { return x > 1; }) == 1; | ||
if (ov::shape_size(const_shape) == 1 || per_channel) { | ||
const auto bias = pattern_map.at(bias_m).get_node_shared_ptr(); | ||
ov::mark_as_bias(bias); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
auto m = std::make_shared<ov::pass::pattern::Matcher>(bias_m, 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
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
Oops, something went wrong.