Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / runtime / contrib / labs / jniacl / src / jniacl_main.cc
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <jni.h>
18 #include <string>
19
20 #include <arm_compute/graph/Graph.h>
21 #include <arm_compute/graph/Nodes.h>
22
23 #include "io_accessor.h"
24
25 extern "C" JNIEXPORT jstring JNICALL
26 Java_com_samsung_testaclexec_ActivityMain_RunACLJNI(JNIEnv *env, jobject)
27 {
28   using arm_compute::DataType;
29   using arm_compute::TensorInfo;
30   using arm_compute::TensorShape;
31   using arm_compute::graph::Graph;
32   using arm_compute::graph::TargetHint;
33   using arm_compute::graph::Tensor;
34
35   arm_compute::graph::Graph graph;
36   TargetHint target_hint = TargetHint::OPENCL;
37   bool autoinc = true;
38
39   graph << target_hint
40         << Tensor(TensorInfo(TensorShape(3U, 3U, 1U, 1U), 1, DataType::F32),
41                   std::unique_ptr<InputAccessor>(new InputAccessor(autoinc)))
42         << arm_compute::graph::ConvolutionLayer(
43              3U, 3U, 1U, std::unique_ptr<WeightAccessor>(new WeightAccessor(autoinc)),
44              std::unique_ptr<BiasAccessor>(new BiasAccessor()),
45              arm_compute::PadStrideInfo(1, 1, 0, 0))
46         << Tensor(std::unique_ptr<OutputAccessor>(new OutputAccessor()));
47
48   graph.run();
49
50   std::string hello = "SoftMax Run OK";
51
52   return env->NewStringUTF(hello.c_str());
53 }