forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtensor.cpp
54 lines (46 loc) · 2.03 KB
/
tensor.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
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <algorithm>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "common_test_utils/test_tools.hpp"
#include "gtest/gtest.h"
#include "ngraph/runtime/host_tensor.hpp"
#include "openvino/core/model.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/relu.hpp"
#include "tensor_conversion_util.hpp"
using namespace std;
using namespace ov;
TEST(tensor, tensor_names) {
auto arg0 = make_shared<ov::op::v0::Parameter>(element::f32, Shape{1});
arg0->set_friendly_name("data");
arg0->get_output_tensor(0).set_names({"input"});
auto relu = make_shared<ov::op::v0::Relu>(arg0);
relu->set_friendly_name("relu");
relu->get_output_tensor(0).set_names({"relu_t", "identity"});
auto f0 = make_shared<Model>(relu, ParameterVector{arg0});
ASSERT_EQ(arg0->get_output_tensor(0).get_names(), relu->get_input_tensor(0).get_names());
ASSERT_EQ(arg0->get_output_tensor(0).get_names(), relu->input_value(0).get_tensor().get_names());
ASSERT_EQ(f0->get_result()->get_input_tensor(0).get_names(), relu->get_output_tensor(0).get_names());
ASSERT_EQ(f0->get_result()->input_value(0).get_tensor().get_names(), relu->get_output_tensor(0).get_names());
}
TEST(tensor, wrap_tensor_with_unspecified_type) {
auto param = std::make_shared<ov::op::v0::Parameter>(element::undefined, ov::PartialShape{});
OPENVINO_SUPPRESS_DEPRECATED_START
auto tensor = ov::util::wrap_tensor(param->output(0));
OPENVINO_SUPPRESS_DEPRECATED_END
// !tensor means that the tensor is not initialized
EXPECT_EQ(!tensor, true);
}
TEST(tensor, wrap_tensor_with_unspecified_type_from_host_tensor) {
OPENVINO_SUPPRESS_DEPRECATED_START
auto host_tensor = std::make_shared<ngraph::runtime::HostTensor>(element::undefined, ov::PartialShape{});
auto tensor = ov::util::wrap_tensor(host_tensor);
OPENVINO_SUPPRESS_DEPRECATED_END
// !tensor means that the tensor is not initialized
EXPECT_EQ(!tensor, true);
}