Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JAVA] add Core constructor #422

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/java_api/cpp/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore(JNIEnv *env, jobjec
return 0;
}

JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore1(JNIEnv *env, jobject obj, jstring xmlConfigFile)
{

JNI_METHOD("GetCore1",
std::string n_xml = jstringToString(env, xmlConfigFile);
Core *core = new Core(n_xml);
return (jlong)core;
)
return 0;
}

JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel(JNIEnv *env, jobject obj, jlong coreAddr, jstring xml)
{
JNI_METHOD("ReadModel",
Expand Down
1 change: 1 addition & 0 deletions modules/java_api/cpp/openvino_java.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ extern "C"

// ov::Core
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore(JNIEnv *, jobject);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore1(JNIEnv *, jobject, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel(JNIEnv *, jobject, jlong, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel1(JNIEnv *, jobject, jlong, jstring, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_CompileModel(JNIEnv *, jobject, jlong, jlong, jstring);
Expand Down
11 changes: 9 additions & 2 deletions modules/java_api/org/intel/openvino/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public Core() {
super(GetCore());
}

public Core(String xmlConfigFile) {
super(GetCore1(xmlConfigFile));
}

private static String getLibraryName(String name, String linux_ver) {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
Expand Down Expand Up @@ -114,15 +118,18 @@ public CompiledModel compile_model(Model net, final String device) {
}

/*----------------------------------- native methods -----------------------------------*/

private static native long GetCore();

private static native long GetCore1(String xmlConfigFile);

private static native long ReadModel(long core, final String modelPath);

private static native long ReadModel1(
long core, final String modelPath, final String weightPath);

private static native long CompileModel(long core, long net, final String device);

private static native long GetCore();

@Override
protected native void delete(long nativeObj);
}