潘志宝
2024-09-12 27e7299964b861c079dbb2826edab00dfd6dc27d
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
\#include "pch.h"
\#include"cstring"
\#include <iostream>  
\#include "framework.h"
\#include <fstream>
\#include <stdio.h>
\#include <stdlib.h>
\#include <string.h>
\#include"${pyName}Jni.h"
 
JNIEXPORT jobject JNICALL Java_${pkgName.replace('.','_')}_impl_${pyName}Impl_${pyName}Train(JNIEnv* env, jobject object1, jobjectArray data_train, jobject settings)
{
    jclass class_hashmap = env->FindClass("java/util/HashMap");
    jmethodID hashmap_construct_method = env->GetMethodID(class_hashmap, "<init>", "()V");
    jobject obj_hashmap = env->NewObject(class_hashmap, hashmap_construct_method, "");
    env->DeleteLocalRef(class_hashmap);
 
    obj_hashmap = ${pyName}_train(env, data_train, settings);
    return  obj_hashmap;
}
 
JNIEXPORT jobject JNICALL Java_${pkgName.replace('.','_')}_impl_${pyName}Impl_${pyName}Predict(JNIEnv* env, jobject object1, #{foreach} ($column in [1..$dataLength])jobjectArray data${column}, #{end}jobject model_path_, jobject settings)
{
    jclass class_hashmap = env->FindClass("java/util/HashMap");
    jmethodID hashmap_construct_method = env->GetMethodID(class_hashmap, "<init>", "()V");
    jobject obj_hashmap = env->NewObject(class_hashmap, hashmap_construct_method, "");
    env->DeleteLocalRef(class_hashmap);
 
    obj_hashmap = ${pyName}_predict(env, #{foreach} ($column in [1..$dataLength])data${column}, #{end}model_path_, settings);
    return  obj_hashmap;
}