2019-03-06 05:27:12 +00:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
#include "core/session/onnxruntime_cxx_api.h"
|
2019-05-10 21:58:50 +00:00
|
|
|
#include <fstream>
|
2019-03-06 05:27:12 +00:00
|
|
|
#include "test_fixture.h"
|
|
|
|
|
#include "file_util.h"
|
2020-02-04 03:33:14 +00:00
|
|
|
extern std::unique_ptr<Ort::Env> ort_env;
|
2019-09-20 20:39:11 +00:00
|
|
|
|
2019-03-06 05:27:12 +00:00
|
|
|
namespace onnxruntime {
|
|
|
|
|
namespace test {
|
2019-05-10 21:58:50 +00:00
|
|
|
|
2020-02-04 03:33:14 +00:00
|
|
|
TEST(CApiTest, model_from_array) {
|
2019-07-04 03:10:29 +00:00
|
|
|
const char* model_path = "testdata/matmul_1.onnx";
|
2019-05-10 21:58:50 +00:00
|
|
|
std::vector<char> buffer;
|
|
|
|
|
{
|
2019-05-24 18:15:51 +00:00
|
|
|
std::ifstream file(model_path, std::ios::binary | std::ios::ate);
|
|
|
|
|
if (!file)
|
|
|
|
|
throw std::runtime_error("Error reading model");
|
|
|
|
|
buffer.resize(file.tellg());
|
|
|
|
|
file.seekg(0, std::ios::beg);
|
|
|
|
|
if (!file.read(buffer.data(), buffer.size()))
|
|
|
|
|
throw std::runtime_error("Error reading model");
|
2019-05-10 21:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-24 18:15:51 +00:00
|
|
|
Ort::SessionOptions so;
|
2020-02-04 03:33:14 +00:00
|
|
|
Ort::Session session(*ort_env.get(), buffer.data(), buffer.size(), so);
|
2019-05-10 21:58:50 +00:00
|
|
|
}
|
2019-03-06 05:27:12 +00:00
|
|
|
} // namespace test
|
2019-03-21 21:06:38 +00:00
|
|
|
} // namespace onnxruntime
|