forked from openvinotoolkit/openvino_contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenvino.cpp
31 lines (25 loc) · 1.16 KB
/
openvino.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
// Copyright (C) 2020-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include <jni.h> // JNI header provided by JDK
#include "openvino/openvino.hpp"
#include "openvino/core/graph_util.hpp"
#include "openvino_java.hpp"
#include "jni_common.hpp"
using namespace ov;
JNIEXPORT void JNICALL Java_org_intel_openvino_Openvino_serialize(JNIEnv *env, jobject obj, jlong modelAddr, jstring xmlPath, jstring binPath)
{
JNI_METHOD("serialize",
std::string xml_path = jstringToString(env, xmlPath);
std::string bin_path = jstringToString(env, binPath);
std::shared_ptr<const Model> *model = reinterpret_cast<std::shared_ptr<const Model> *>(modelAddr);
serialize(*model, xml_path, bin_path);
)
}
JNIEXPORT void JNICALL Java_org_intel_openvino_Openvino_SaveModel(JNIEnv *env, jobject obj, jlong modelAddr, jstring outputModel, jboolean compressToFp16)
{
JNI_METHOD("SaveModel",
std::string n_output_model = jstringToString(env, outputModel);
std::shared_ptr<const Model> *model = reinterpret_cast<std::shared_ptr<const Model> *>(modelAddr);
save_model(*model, n_output_model, (bool) compressToFp16);
)
}