summaryrefslogtreecommitdiff
path: root/runtimes/contrib/labs/jniacl/src/jniacl_main.cc
blob: 4e5f10d1f6d5c921be2a5baad28024d9b15c1099 (plain)
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
32
33
34
35
36
37
#include <jni.h>
#include <string>

#include <arm_compute/graph/Graph.h>
#include <arm_compute/graph/Nodes.h>

#include "io_accessor.h"

extern "C" JNIEXPORT jstring JNICALL
Java_com_samsung_testaclexec_ActivityMain_RunACLJNI(JNIEnv *env, jobject)
{
  using arm_compute::DataType;
  using arm_compute::graph::Tensor;
  using arm_compute::graph::TargetHint;
  using arm_compute::graph::Graph;
  using arm_compute::TensorInfo;
  using arm_compute::TensorShape;

  arm_compute::graph::Graph graph;
  TargetHint target_hint = TargetHint::OPENCL;
  bool autoinc = true;

  graph << target_hint << Tensor(TensorInfo(TensorShape(3U, 3U, 1U, 1U), 1, DataType::F32),
                                 std::unique_ptr<InputAccessor>(new InputAccessor(autoinc)))
        << arm_compute::graph::ConvolutionLayer(
               3U, 3U, 1U, std::unique_ptr<WeightAccessor>(new WeightAccessor(autoinc)),
               std::unique_ptr<BiasAccessor>(new BiasAccessor()),
               arm_compute::PadStrideInfo(1, 1, 0, 0))
        << Tensor(std::unique_ptr<OutputAccessor>(new OutputAccessor()));
  ;

  graph.run();

  std::string hello = "SoftMax Run OK";

  return env->NewStringUTF(hello.c_str());
}