Skip to content

Commit e0ab94b

Browse files
committed
Merge branch 'ovep-develop' into jatin_ub_lb_redesign
2 parents 1efe73e + 5ec3c7e commit e0ab94b

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

cmake/onnxruntime_unittests.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ if(onnxruntime_USE_AZURE)
770770
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_azure)
771771
endif()
772772

773+
if (onnxruntime_USE_OPENVINO)
774+
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/openvino/*)
775+
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_openvino)
776+
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_openvino)
777+
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_shared)
778+
endif()
779+
773780
file(GLOB onnxruntime_test_framework_src CONFIGURE_DEPENDS
774781
${onnxruntime_test_framework_src_patterns}
775782
)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#include <filesystem>
5+
#include <string>
6+
7+
#include "core/framework/provider_options.h"
8+
#include "core/framework/tensor_shape.h"
9+
#include "core/framework/float16.h"
10+
11+
#include "test/util/include/test_utils.h"
12+
#include "test/util/include/test/test_environment.h"
13+
#include "test/util/include/default_providers.h"
14+
15+
#include "core/session/onnxruntime_cxx_api.h"
16+
#include "core/session/onnxruntime_session_options_config_keys.h"
17+
#include "core/session/inference_session.h"
18+
#include "core/graph/model_saving_options.h"
19+
20+
#include "test/optimizer/qdq_test_utils.h"
21+
22+
#include "gtest/gtest.h"
23+
#include "gmock/gmock.h"
24+
25+
using namespace ONNX_NAMESPACE;
26+
using namespace onnxruntime::logging;
27+
28+
29+
extern std::unique_ptr<Ort::Env> ort_env;
30+
31+
class OVEPEPContextTests : public ::testing::Test {
32+
33+
34+
};
35+
36+
namespace onnxruntime {
37+
namespace test {
38+
39+
40+
// Test if folder path given to ep_context_file_path throws an error
41+
TEST_F(OVEPEPContextTests, OVEPEPContextFolderPath) {
42+
43+
Ort::SessionOptions sessionOptions;
44+
std::unordered_map<std::string, std::string> ov_options;
45+
46+
//The below line could fail the test in non NPU platforms.Commenting it out so that the device used for building OVEP will be used.
47+
//ov_options["device_type"] = "NPU";
48+
49+
50+
const std::unordered_map<std::string, int> domain_to_version = {{"", 13}, {kMSDomain, 1}};
51+
52+
auto& logging_manager = DefaultLoggingManager();
53+
logging_manager.SetDefaultLoggerSeverity(logging::Severity::kERROR);
54+
55+
onnxruntime::Model model("OVEP_Test_Model", false, ModelMetaData(), PathString(),
56+
IOnnxRuntimeOpSchemaRegistryList(), domain_to_version, {},
57+
logging_manager.DefaultLogger());
58+
59+
ASSERT_STATUS_OK(model.MainGraph().Resolve());
60+
61+
// Serialize the model to a string.
62+
std::string model_data;
63+
model.ToProto().SerializeToString(&model_data);
64+
65+
const auto model_data_span = AsByteSpan(model_data.data(), model_data.size());
66+
67+
const std::string ep_context_file_path = "./ep_context_folder_path/";
68+
69+
70+
sessionOptions.AddConfigEntry(kOrtSessionOptionEpContextEnable, "1");
71+
sessionOptions.AddConfigEntry(kOrtSessionOptionEpContextFilePath,ep_context_file_path.c_str());
72+
sessionOptions.AppendExecutionProvider_OpenVINO_V2(ov_options);
73+
74+
75+
try {
76+
Ort::Session session(*ort_env, model_data_span.data(), model_data_span.size(), sessionOptions);
77+
FAIL(); // Should not get here!
78+
} catch (const Ort::Exception& excpt) {
79+
ASSERT_EQ(excpt.GetOrtErrorCode(), ORT_INVALID_ARGUMENT);
80+
ASSERT_THAT(excpt.what(), testing::HasSubstr("context_file_path should not point to a folder."));
81+
}
82+
83+
}
84+
85+
86+
} // namespace test
87+
} // namespace onnxruntime

0 commit comments

Comments
 (0)