forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op.cpp
69 lines (62 loc) · 1.87 KB
/
op.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
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <memory>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include "openvino/op/add.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/util/op_types.hpp"
#include "openvino/opsets/opset.hpp"
using namespace std;
using namespace ov;
TEST(op, is_op) {
auto arg0 = make_shared<ov::op::v0::Parameter>(element::f32, Shape{1});
ASSERT_NE(nullptr, arg0);
EXPECT_TRUE(op::util::is_parameter(arg0));
}
TEST(op, is_parameter) {
auto arg0 = make_shared<ov::op::v0::Parameter>(element::f32, Shape{1});
ASSERT_NE(nullptr, arg0);
auto t0 = make_shared<op::v1::Add>(arg0, arg0);
ASSERT_NE(nullptr, t0);
EXPECT_FALSE(op::util::is_parameter(t0));
}
TEST(op, opset_multi_thread) {
auto doTest = [&](std::function<const ov::OpSet&()> fun) {
std::atomic<const ov::OpSet*> opset{nullptr};
std::atomic_bool failed{false};
auto threadFun = [&]() {
const ov::OpSet* op = &fun();
const ov::OpSet* current = opset;
do {
if (current != nullptr && current != op) {
failed = true;
break;
}
} while (opset.compare_exchange_strong(op, current));
};
std::thread t1{threadFun};
std::thread t2{threadFun};
t1.join();
t2.join();
ASSERT_FALSE(failed);
};
doTest(ov::get_opset1);
doTest(ov::get_opset2);
doTest(ov::get_opset3);
doTest(ov::get_opset4);
doTest(ov::get_opset5);
doTest(ov::get_opset6);
doTest(ov::get_opset7);
doTest(ov::get_opset8);
doTest(ov::get_opset9);
doTest(ov::get_opset10);
doTest(ov::get_opset11);
doTest(ov::get_opset12);
doTest(ov::get_opset13);
doTest(ov::get_opset14);
}