|
| 1 | +// Copyright (C) 2020-2023 Intel Corporation |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +#include <jni.h> // JNI header provided by JDK |
| 5 | +#include "openvino/openvino.hpp" |
| 6 | + |
| 7 | +#include "openvino_java.hpp" |
| 8 | +#include "jni_common.hpp" |
| 9 | + |
| 10 | +using namespace ov; |
| 11 | + |
| 12 | +JNIEXPORT jlong JNICALL Java_org_intel_openvino_PartialShape_GetDimension(JNIEnv *env, jobject obj, jlong addr, jint index) { |
| 13 | + JNI_METHOD("GetDimension", |
| 14 | + PartialShape* partial_shape = (PartialShape *)addr; |
| 15 | + return (jlong) &(*partial_shape)[index]; |
| 16 | + ) |
| 17 | + return 0; |
| 18 | +} |
| 19 | + |
| 20 | +JNIEXPORT jintArray JNICALL Java_org_intel_openvino_PartialShape_GetMaxShape(JNIEnv *env, jobject obj, jlong addr) { |
| 21 | + JNI_METHOD("GetMaxShape", |
| 22 | + PartialShape* partial_shape = (PartialShape *)addr; |
| 23 | + Shape max_shape = partial_shape->get_max_shape(); |
| 24 | + |
| 25 | + jintArray result = env->NewIntArray(max_shape.size()); |
| 26 | + if (!result) { |
| 27 | + throw std::runtime_error("Out of memory!"); |
| 28 | + } jint *arr = env->GetIntArrayElements(result, nullptr); |
| 29 | + |
| 30 | + for (int i = 0; i < max_shape.size(); ++i) |
| 31 | + arr[i] = max_shape[i]; |
| 32 | + |
| 33 | + env->ReleaseIntArrayElements(result, arr, 0); |
| 34 | + return result; |
| 35 | + ) |
| 36 | + return 0; |
| 37 | +} |
| 38 | + |
| 39 | +JNIEXPORT jintArray JNICALL Java_org_intel_openvino_PartialShape_GetMinShape(JNIEnv *env, jobject obj, jlong addr) { |
| 40 | + JNI_METHOD("GetMinShape", |
| 41 | + PartialShape* partial_shape = (PartialShape *)addr; |
| 42 | + Shape min_shape = partial_shape->get_min_shape(); |
| 43 | + |
| 44 | + jintArray result = env->NewIntArray(min_shape.size()); |
| 45 | + if (!result) { |
| 46 | + throw std::runtime_error("Out of memory!"); |
| 47 | + } jint *arr = env->GetIntArrayElements(result, nullptr); |
| 48 | + |
| 49 | + for (int i = 0; i < min_shape.size(); ++i) |
| 50 | + arr[i] = min_shape[i]; |
| 51 | + |
| 52 | + env->ReleaseIntArrayElements(result, arr, 0); |
| 53 | + return result; |
| 54 | + ) |
| 55 | + return 0; |
| 56 | +} |
0 commit comments