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.
[ONNX] QLinearConvolution (openvinotoolkit#7210)
- Loading branch information
Showing
21 changed files
with
533 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// Disabled in CMakeList | ||
// Update to higher opset required | ||
|
||
#include "op/qlinear_conv.hpp" | ||
|
||
#include <cstddef> | ||
#include <memory> | ||
#include <vector> | ||
|
||
#include "conv.hpp" | ||
#include "dequantize_linear.hpp" | ||
#include "exceptions.hpp" | ||
#include "ngraph/opsets/opset6.hpp" | ||
#include "onnx_import/core/null_node.hpp" | ||
#include "quantize_linear.hpp" | ||
|
||
namespace ngraph { | ||
namespace onnx_import { | ||
namespace op { | ||
namespace set_1 { | ||
OutputVector qlinear_conv(const Node& node) { | ||
const OutputVector& inputs = node.get_ng_inputs(); | ||
|
||
auto x = inputs.at(0); | ||
auto x_scale = inputs.at(1); | ||
auto x_zero_point = inputs.at(2); | ||
auto w = inputs.at(3); | ||
auto w_scale = inputs.at(4); | ||
auto w_zero_point = inputs.at(5); | ||
auto y_scale = inputs.at(6); | ||
auto y_zero_point = inputs.at(7); | ||
Output<ngraph::Node> B = inputs.size() > 8 ? inputs.at(8) : std::make_shared<NullNode>()->output(0); | ||
|
||
x = set_13::detail::dequantize_linear(x, | ||
x_scale, | ||
std::make_shared<opset6::Convert>(x_zero_point, element::f32), | ||
1, | ||
node)[0]; | ||
w = set_13::detail::dequantize_linear(w, | ||
w_scale, | ||
std::make_shared<opset6::Convert>(w_zero_point, element::f32), | ||
1, | ||
node)[0]; | ||
|
||
if (!ngraph::op::is_null(B)) { | ||
B = std::make_shared<opset6::Multiply>(std::make_shared<opset6::Convert>(B, x_scale.get_element_type()), | ||
std::make_shared<opset6::Multiply>(x_scale, w_scale)) | ||
->output(0); | ||
} | ||
|
||
auto result = detail::conv(node, x, w, B)[0]; | ||
|
||
result = op::detail::make_fake_quantize(y_scale, y_zero_point, result); | ||
|
||
return {result}; | ||
} | ||
|
||
} // namespace set_1 | ||
|
||
} // namespace op | ||
|
||
} // namespace onnx_import | ||
|
||
} // namespace ngraph |
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,31 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// Disabled in CMakeList | ||
// Update to higher opset required | ||
|
||
#pragma once | ||
|
||
#include "ngraph/node.hpp" | ||
#include "onnx_import/core/node.hpp" | ||
|
||
namespace ngraph { | ||
namespace onnx_import { | ||
namespace op { | ||
namespace set_1 { | ||
/// \brief Performs ONNX QLinearConv operation. | ||
/// | ||
/// \param node The ONNX node object representing this operation. | ||
/// | ||
/// \return The vector containing Ngraph nodes producing output of ONNX quantizied | ||
/// convolution operation. | ||
OutputVector qlinear_conv(const Node& node); | ||
|
||
} // namespace set_1 | ||
|
||
} // namespace op | ||
|
||
} // namespace onnx_import | ||
|
||
} // namespace ngraph |
Oops, something went wrong.