forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_api.cpp
More file actions
76 lines (57 loc) · 2.75 KB
/
Copy pathbasic_api.cpp
File metadata and controls
76 lines (57 loc) · 2.75 KB
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
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "basic_api.hpp"
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/test_assertions.hpp"
#include "openvino/frontend/paddle/frontend.hpp"
#include "openvino/util/file_util.hpp"
#include "paddle_utils.hpp"
using namespace ov::frontend;
using PaddleBasicTest = FrontEndBasicTest;
static const std::vector<std::string> models{
std::string("conv2d/conv2d.pdmodel"),
std::string("conv2d_relu/conv2d_relu.pdmodel"),
std::string("2in_2out/2in_2out.pdmodel"),
std::string("multi_tensor_split/multi_tensor_split.pdmodel"),
std::string("2in_2out_dynbatch/2in_2out_dynbatch.pdmodel"),
};
INSTANTIATE_TEST_SUITE_P(PaddleBasicTest,
FrontEndBasicTest,
::testing::Combine(::testing::Values(PADDLE_FE),
::testing::Values(std::string(TEST_PADDLE_MODELS_DIRNAME)),
::testing::ValuesIn(models)),
FrontEndBasicTest::getTestCaseName);
TEST(PaddleBasicTest, check_supported_legacy_model) {
const auto test_dir = std::filesystem::path(ov::test::utils::generateTestFilePrefix());
const auto legacy_model_path = test_dir / "paddle_legacy.model";
{
ov::util::create_directory_recursive(legacy_model_path);
std::ofstream model(legacy_model_path / "__model__");
model << "Fake model data which are not important for this test";
}
paddle::FrontEnd fe;
EXPECT_TRUE(fe.supported({{legacy_model_path.native()}, {false}}));
EXPECT_TRUE(fe.supported({{legacy_model_path}, {false}}));
std::filesystem::remove_all(test_dir);
}
TEST(PaddleBasicTest, check_supported_legacy_model_not_exists) {
const auto test_dir = std::filesystem::path(ov::test::utils::generateTestFilePrefix());
const auto legacy_model_path = test_dir / "dir.with_dot" / "paddle_legacy_model";
paddle::FrontEnd fe;
OV_EXPECT_THROW(fe.supported({{legacy_model_path.native()}, {false}}), ov::Exception, testing::_);
OV_EXPECT_THROW(fe.supported({{legacy_model_path}, false}), ov::Exception, testing::_);
}
TEST(PaddleBasicTest, check_supported_incorrect_extension) {
const auto test_dir = std::filesystem::path(ov::test::utils::generateTestFilePrefix());
const auto model_path = test_dir / "model.onnx";
{
ov::util::create_directory_recursive(test_dir);
std::ofstream model(model_path);
model << "Fake model data which are not important for this test";
}
paddle::FrontEnd fe;
EXPECT_FALSE(fe.supported({{model_path.native()}, {false}}));
EXPECT_FALSE(fe.supported({{model_path}, {false}}));
std::filesystem::remove_all(test_dir);
}