forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtti.cpp
96 lines (82 loc) · 3.08 KB
/
rtti.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "gtest/gtest.h"
#include "ngraph/node.hpp"
#include "util/all_close_f.hpp"
#include "util/test_tools.hpp"
using namespace ngraph;
using namespace std;
class OpType : public ngraph::op::Op {
public:
OPENVINO_OP("OpType");
OpType() = default;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override {
return nullptr;
}
};
class OpTypeVersion : public ngraph::op::Op {
public:
OPENVINO_OP("OpTypeVersion", "my_version");
OpTypeVersion() = default;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override {
return nullptr;
}
};
class OpTypeVersionParent : public OpType {
public:
OPENVINO_OP("OpTypeVersionParent", "my_version", OpType);
OpTypeVersionParent() = default;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override {
return nullptr;
}
};
class OpTypeVersionParentOld : public OpType {
public:
OPENVINO_OP("OpTypeVersionParentOld", "my_version1", OpType, 1);
OpTypeVersionParentOld() = default;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override {
return nullptr;
}
};
OPENVINO_SUPPRESS_DEPRECATED_START
TEST(rtti, op_with_type) {
auto op = OpType();
auto type_info = op.get_type_info();
ASSERT_EQ(type_info, OpType::get_type_info_static());
ASSERT_EQ(strcmp(type_info.name, "OpType"), 0);
ASSERT_EQ(type_info.version, 0);
ASSERT_EQ(strcmp(type_info.version_id, "extension"), 0);
ASSERT_NE(type_info.parent, nullptr);
ASSERT_EQ(*type_info.parent, ngraph::op::Op::get_type_info_static());
}
TEST(rtti, op_with_type_version) {
auto op = OpTypeVersion();
auto type_info = op.get_type_info();
ASSERT_EQ(type_info, OpTypeVersion::get_type_info_static());
ASSERT_EQ(strcmp(type_info.name, "OpTypeVersion"), 0);
ASSERT_EQ(type_info.version, 0);
ASSERT_EQ(strcmp(type_info.version_id, "my_version"), 0);
ASSERT_NE(type_info.parent, nullptr);
ASSERT_EQ(*type_info.parent, ngraph::op::Op::get_type_info_static());
}
TEST(rtti, op_with_type_version_parent) {
auto op = OpTypeVersionParent();
auto type_info = op.get_type_info();
ASSERT_EQ(type_info, OpTypeVersionParent::get_type_info_static());
ASSERT_EQ(strcmp(type_info.name, "OpTypeVersionParent"), 0);
ASSERT_EQ(type_info.version, 0);
ASSERT_EQ(strcmp(type_info.version_id, "my_version"), 0);
ASSERT_NE(type_info.parent, nullptr);
ASSERT_EQ(*type_info.parent, OpType::get_type_info_static());
}
TEST(rtti, op_with_type_version_parent_old) {
auto op = OpTypeVersionParentOld();
auto type_info = op.get_type_info();
ASSERT_EQ(type_info, OpTypeVersionParentOld::get_type_info_static());
ASSERT_EQ(strcmp(type_info.name, "OpTypeVersionParentOld"), 0);
ASSERT_EQ(strcmp(type_info.version_id, "my_version1"), 0);
ASSERT_EQ(type_info.version, 1);
ASSERT_NE(type_info.parent, nullptr);
ASSERT_EQ(*type_info.parent, OpType::get_type_info_static());
}