Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snippets] Serialization/Deserialization enabled #14064

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
47aad8d
Code snippets serialization in CPU plugin
vladislav-volkov Mar 14, 2022
52196e1
Fix Subgraph serialization
mmikolajcz Jul 4, 2022
e88998d
Merge branch 'master' of https://github.com/mmikolajcz/openvino
mmikolajcz Jul 4, 2022
728fb1e
Merge branch 'master' into master
mmikolajcz Jul 5, 2022
7d0db54
Merge branch 'master' into master
mmikolajcz Jul 6, 2022
d4a84a6
Fix indent alignment
mmikolajcz Jul 8, 2022
566fb5d
Merge branch 'openvinotoolkit:master' into master
mmikolajcz Jul 18, 2022
5132f27
Add submodule serialization test
mmikolajcz Jul 18, 2022
6ab4a17
Merge branch 'master' of https://github.com/mmikolajcz/openvino
mmikolajcz Jul 18, 2022
4bdf145
Fix test
mmikolajcz Jul 18, 2022
fe0359c
Merge branch 'master' into master
mmikolajcz Aug 2, 2022
8a9c9d0
Move test to functional
mmikolajcz Aug 4, 2022
e284b26
Merge branch 'master' into master
mmikolajcz Aug 8, 2022
8b90f82
Merge branch 'master' into master
mmikolajcz Aug 9, 2022
d2f9ff4
Merge branch 'master' into master
mmikolajcz Aug 10, 2022
9085698
Add Scalar Constant test
mmikolajcz Aug 16, 2022
76a1d64
Merge branch 'master' of https://github.com/mmikolajcz/openvino
mmikolajcz Aug 16, 2022
b08bb79
Merge branch 'master' of https://github.com/openvinotoolkit/openvino
mmikolajcz Aug 23, 2022
5bc1c47
Merge branch 'dev-snippets-serialization' of https://github.com/vladi…
mmikolajcz Aug 23, 2022
f7e0f80
Fix duplication
mmikolajcz Aug 23, 2022
4ab7c65
Fix failing Snippet tests
mmikolajcz Aug 31, 2022
2a28c96
Merge branch 'master' of https://github.com/openvinotoolkit/openvino
mmikolajcz Aug 31, 2022
1cec81a
Fix MR conflicts
mmikolajcz Aug 31, 2022
1dc0d07
Add additional assert to tests
mmikolajcz Sep 1, 2022
9215efa
Changes requested in review
mmikolajcz Sep 2, 2022
27cfcfd
Merge branch 'master' into master
mmikolajcz Sep 5, 2022
6ba5a85
Use body_ptr()
mmikolajcz Sep 7, 2022
d2c216a
Disable transformations
mmikolajcz Sep 7, 2022
893494a
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 17, 2022
c3f17e7
Disabled subgraph descriptors check in Lowering tests
v-Golubev Nov 17, 2022
c8ac231
Transformation calls prohibited for snippets::Subgraph body in GraphR…
v-Golubev Nov 17, 2022
363730c
Merge branch 'master' into vg/snippets/serialization
peterchen-intel Nov 18, 2022
ef21198
review comments applied
v-Golubev Nov 18, 2022
aba19f9
Snippets opset added to extensions
v-Golubev Nov 18, 2022
496b943
Macroses added for all snippets ops
v-Golubev Nov 18, 2022
fce5825
Compilation error fixed
v-Golubev Nov 20, 2022
e31fa21
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 22, 2022
5765e18
Revert "Macroses added for all snippets ops"
v-Golubev Nov 22, 2022
8e8d5d2
all snippets ops added to extensions
v-Golubev Nov 22, 2022
17ea1c2
in/out names restored from the cache
v-Golubev Nov 23, 2022
c5e127b
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 23, 2022
6d644a0
CollapseSubgraph: friendly_name fix for Subgraphs before Result
v-Golubev Nov 25, 2022
870fffd
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 25, 2022
e048bd1
Added test case for Subgraph naming before Result
v-Golubev Nov 28, 2022
904ea2b
Added test case with Result as 1st Subgraph's output
v-Golubev Nov 28, 2022
eca6a92
typo fix
v-Golubev Nov 28, 2022
7e2045c
UniqueNamesHolder::init_names: set fr_name only if the current one is…
v-Golubev Nov 28, 2022
30ad16c
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 29, 2022
19bc7e6
init_names quick fix
v-Golubev Nov 29, 2022
3bbd571
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
v-Golubev Nov 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/common/snippets/include/snippets/op/broadcastload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,9 @@ class BroadcastLoad : public BroadcastMove {
BroadcastLoad(const Output<Node>& x, Shape output_shape);
BroadcastLoad() = default;

bool visit_attributes(AttributeVisitor& visitor) override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

void validate_and_infer_types() override;

void set_broadcast_info(const Shape& bct) {
broadcast_info = bct;
}

bool is_broadcast(size_t idx) {
return broadcast_info[idx] == 1;
}

private:
Shape broadcast_info;
};

} // namespace op
Expand Down
1 change: 1 addition & 0 deletions src/common/snippets/include/snippets/op/powerstatic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace op {
class PowerStatic : public ov::op::util::UnaryElementwiseArithmetic {
public:
OPENVINO_OP("PowerStatic", "SnippetsOpset", ov::op::util::UnaryElementwiseArithmetic);
BWDCMP_RTTI_DECLARATION;

PowerStatic() = default;
PowerStatic(const Output <Node> &arg, float power) : UnaryElementwiseArithmetic(arg), power(power) {
Expand Down
3 changes: 3 additions & 0 deletions src/common/snippets/include/snippets/op/scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ namespace op {
class Scalar : public ov::op::v0::Constant {
public:
OPENVINO_OP("Scalar", "SnippetsOpset", ov::op::v0::Constant);
BWDCMP_RTTI_DECLARATION;

Scalar() = default;

template <class T, class = typename std::enable_if<std::is_fundamental<T>::value>::type>
Scalar(const element::Type& type, Shape shape, T value) : Constant(type, shape, value) {
Expand Down
34 changes: 28 additions & 6 deletions src/common/snippets/include/snippets/op/subgraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#include <openvino/core/model.hpp>
#include <openvino/op/util/sub_graph_base.hpp>
#include <ngraph/op/op.hpp>
#include <ngraph/rt_info.hpp>
#include <ngraph/pass/manager.hpp>
Expand All @@ -22,9 +23,10 @@ namespace op {
* @brief An operation that is implemented by a model
* @ingroup snippets
*/
class Subgraph : public ngraph::op::Op {
class Subgraph : public ov::op::util::SubGraphOp {
public:
OPENVINO_OP("Subgraph", "SnippetsOpset");
OPENVINO_OP("Subgraph", "SnippetsOpset", ov::op::util::SubGraphOp);
BWDCMP_RTTI_DECLARATION;

// < 1, 42, 17, 15, 16> < 0, 1, 2, 3, 1>
// should be:
Expand Down Expand Up @@ -70,6 +72,8 @@ class Subgraph : public ngraph::op::Op {
using BlockedShape = std::tuple<ngraph::Shape, ngraph::AxisVector, ngraph::element::Type>;
using BlockedShapeVector = std::vector<BlockedShape>;

Subgraph() = default;

Subgraph(const OutputVector& args, std::shared_ptr<ov::Model> body);

Subgraph(const NodeVector& args, std::shared_ptr<ov::Model> body);
Expand All @@ -80,11 +84,29 @@ class Subgraph : public ngraph::op::Op {

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;

std::shared_ptr<ov::Model> get_body() const {
return m_body;
// we introduce this method instead of using SubGraphOp::get_function()
// to align naming with other methods
const std::shared_ptr<ov::Model> & body_ptr() const {
return m_bodies[0];
v-Golubev marked this conversation as resolved.
Show resolved Hide resolved
}

std::shared_ptr<ov::Model> & body_ptr() {
return m_bodies[0];
}

std::shared_ptr<ngraph::snippets::Generator> get_generator() const {
const ov::Model & body() const {
return *m_bodies[0];
}

ov::Model & body() {
return *m_bodies[0];
}

const std::shared_ptr<ngraph::snippets::Generator> & get_generator() const {
return m_generator;
}

std::shared_ptr<ngraph::snippets::Generator> & get_generator() {
return m_generator;
}

Expand Down Expand Up @@ -123,13 +145,13 @@ class Subgraph : public ngraph::op::Op {
private:
void align_element_types(const BlockedShapeVector& outputShapes, const BlockedShapeVector& inputShapes);
void convert_to_snippet_dialect();

// Count of potentional non-scalar Consants that will be created after some tranformations
// At the moment it's relevant only for FakeQuantize decomposition
// NOTE: To avoid overheads in each calcution of this count (for example, in validate_and_type_infer()),
// we should MANUALLY calculate it where it needed.
size_t m_non_scalar_constants_count = 0;
Shape exec_domain = {};
std::shared_ptr<ov::Model> m_body = nullptr;
std::shared_ptr<ngraph::snippets::Generator> m_generator = nullptr;

// TODO: Change logic of insert Converts. This exec element type can be different for plugins
Expand Down
10 changes: 2 additions & 8 deletions src/common/snippets/src/op/broadcastload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ using namespace std;
using namespace ngraph;

snippets::op::BroadcastLoad::BroadcastLoad(const Output<Node>& x, Shape shape)
: BroadcastMove(x, shape), broadcast_info(x.get_shape().size(), 0) {
: BroadcastMove(x, shape) {
constructor_validate_and_infer_types();
}

bool snippets::op::BroadcastLoad::visit_attributes(AttributeVisitor& visitor) {
return true;
}

std::shared_ptr<Node> snippets::op::BroadcastLoad::clone_with_new_inputs(const OutputVector& new_args) const {
INTERNAL_OP_SCOPE(BroadcastLoad);
check_new_args_count(this, new_args);
auto other = std::make_shared<BroadcastLoad>(new_args.at(0), output_shape);
other->set_broadcast_info(this->broadcast_info);
return other;
return std::make_shared<BroadcastLoad>(new_args.at(0), output_shape);
}

void snippets::op::BroadcastLoad::validate_and_infer_types() {
Expand Down
1 change: 1 addition & 0 deletions src/common/snippets/src/op/broadcastmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ snippets::op::BroadcastMove::BroadcastMove(const Output<Node>& x, Shape shape) :
}

bool snippets::op::BroadcastMove::visit_attributes(AttributeVisitor& visitor) {
visitor.on_attribute("output_shape", output_shape);
v-Golubev marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down
15 changes: 15 additions & 0 deletions src/common/snippets/src/op/powerstatic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "snippets/op/powerstatic.hpp"

namespace ngraph {
namespace snippets {
namespace op {

BWDCMP_RTTI_DEFINITION(PowerStatic);

} // namespace op
} // namespace snippets
} // namespace ngraph
2 changes: 2 additions & 0 deletions src/common/snippets/src/op/scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

using namespace ngraph;

BWDCMP_RTTI_DEFINITION(snippets::op::Scalar);
IvanNovoselov marked this conversation as resolved.
Show resolved Hide resolved

std::shared_ptr<Node> snippets::op::Scalar::clone_with_new_inputs(const OutputVector& new_args) const {
check_new_args_count(this, new_args);
return std::make_shared<Scalar>(*this);
Expand Down
Loading