Introduce nnapi_template (#388)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 3 Apr 2018 13:49:33 +0000 (22:49 +0900)
committer이성재/동작제어Lab(SR)/Principal Engineer/삼성전자 <sj925.lee@samsung.com>
Tue, 3 Apr 2018 13:49:33 +0000 (22:49 +0900)
This commit introduces nnapi_template which provides a dummy NN API
implementation in order to make it easy to introduce an experimental NN
API implementation.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
12 files changed:
tools/nnapi_bindings/bindings/CMakeLists.txt
tools/nnapi_bindings/bindings/template/CMakeLists.txt [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/compilation.cc [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/compilation.h [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/event.cc [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/event.h [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/execution.cc [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/execution.h [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/memory.cc [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/memory.h [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/model.cc [new file with mode: 0644]
tools/nnapi_bindings/bindings/template/src/model.h [new file with mode: 0644]

diff --git a/tools/nnapi_bindings/bindings/template/CMakeLists.txt b/tools/nnapi_bindings/bindings/template/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0c5c72c
--- /dev/null
@@ -0,0 +1,5 @@
+file(GLOB_RECURSE SOURCES "src/*.cc")
+
+add_library(nnapi_template SHARED ${SOURCES})
+target_include_directories(nnapi_template PUBLIC ${NNAPI_INCLUDE_DIR})
+set_target_properties(nnapi_template PROPERTIES OUTPUT_NAME neuralnetworks)
diff --git a/tools/nnapi_bindings/bindings/template/src/compilation.cc b/tools/nnapi_bindings/bindings/template/src/compilation.cc
new file mode 100644 (file)
index 0000000..98b0722
--- /dev/null
@@ -0,0 +1,15 @@
+#include <nnapi.h>
+
+#include "compilation.h"
+
+ResultCode
+ANeuralNetworksCompilation_create(ANeuralNetworksModel* model, ANeuralNetworksCompilation** compilation)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksCompilation_finish(ANeuralNetworksCompilation* compilation)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
diff --git a/tools/nnapi_bindings/bindings/template/src/compilation.h b/tools/nnapi_bindings/bindings/template/src/compilation.h
new file mode 100644 (file)
index 0000000..7a28742
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __COMPILATION_H__
+#define __COMPILATION_H__
+
+struct ANeuralNetworksCompilation
+{
+};
+
+#endif
diff --git a/tools/nnapi_bindings/bindings/template/src/event.cc b/tools/nnapi_bindings/bindings/template/src/event.cc
new file mode 100644 (file)
index 0000000..b26b707
--- /dev/null
@@ -0,0 +1,16 @@
+#include <nnapi.h>
+
+#include "event.h"
+
+ResultCode
+ANeuralNetworksEvent_wait(ANeuralNetworksEvent* event)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksEvent_free(ANeuralNetworksEvent* event)
+{
+  delete event;
+  return ANEURALNETWORKS_NO_ERROR;
+}
diff --git a/tools/nnapi_bindings/bindings/template/src/event.h b/tools/nnapi_bindings/bindings/template/src/event.h
new file mode 100644 (file)
index 0000000..7197f04
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __EVENT_H__
+#define __EVENT_H__
+
+struct ANeuralNetworksEvent
+{
+};
+
+#endif
diff --git a/tools/nnapi_bindings/bindings/template/src/execution.cc b/tools/nnapi_bindings/bindings/template/src/execution.cc
new file mode 100644 (file)
index 0000000..d04244f
--- /dev/null
@@ -0,0 +1,36 @@
+#include <nnapi.h>
+
+#include "execution.h"
+
+ResultCode
+ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksExecution_setInput(ANeuralNetworksExecution* execution, 
+                                 int32_t index, const ANeuralNetworksOperandType* type,
+                                 const void* buffer, size_t length)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution* execution, 
+                                   int32_t index, const ANeuralNetworksOperandType* type,
+                                   const void* buffer, size_t length)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execution, ANeuralNetworksEvent** event)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode ANeuralNetworksExecution_free(ANeuralNetworksExecution* execution)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
diff --git a/tools/nnapi_bindings/bindings/template/src/execution.h b/tools/nnapi_bindings/bindings/template/src/execution.h
new file mode 100644 (file)
index 0000000..84d4e88
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __EXECUTION_H__
+#define __EXECUTION_H__
+
+struct ANeuralNetworksExecution
+{
+};
+
+#endif
diff --git a/tools/nnapi_bindings/bindings/template/src/memory.cc b/tools/nnapi_bindings/bindings/template/src/memory.cc
new file mode 100644 (file)
index 0000000..f031933
--- /dev/null
@@ -0,0 +1,19 @@
+#include <nnapi.h>
+
+#include "memory.h"
+
+ResultCode
+ANeuralNetworksMemory_createFromFd(size_t size, int protect, int fd, size_t offset, ANeuralNetworksMemory** memory)
+{
+  *memory = new ANeuralNetworksMemory{};
+
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksMemory_free(ANeuralNetworksMemory* memory)
+{
+  delete memory;
+
+  return ANEURALNETWORKS_NO_ERROR;
+}
diff --git a/tools/nnapi_bindings/bindings/template/src/memory.h b/tools/nnapi_bindings/bindings/template/src/memory.h
new file mode 100644 (file)
index 0000000..a4fed82
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __MEMORY_H__
+#define __MEMORY_H__
+
+struct ANeuralNetworksMemory
+{
+};
+
+#endif // __MEMORY_H__
diff --git a/tools/nnapi_bindings/bindings/template/src/model.cc b/tools/nnapi_bindings/bindings/template/src/model.cc
new file mode 100644 (file)
index 0000000..3b064f1
--- /dev/null
@@ -0,0 +1,59 @@
+#include <nnapi.h>
+
+#include "model.h"
+
+ResultCode
+ANeuralNetworksModel_create(ANeuralNetworksModel** model)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_free(ANeuralNetworksModel* model)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_addOperand(ANeuralNetworksModel* model, const ANeuralNetworksOperandType *type)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel* model,
+                                     int32_t index,
+                                     const void* buffer, size_t length)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_setOperandValueFromMemory(ANeuralNetworksModel* model,
+                                               int32_t index,
+                                               const ANeuralNetworksMemory* memory, size_t offset, size_t length)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_addOperation(ANeuralNetworksModel* model,
+                                  ANeuralNetworksOperationType type,
+                                  uint32_t inputCount, const uint32_t* inputs,
+                                  uint32_t outputCount, const uint32_t* outputs)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode
+ANeuralNetworksModel_identifyInputsAndOutputs(ANeuralNetworksModel* model,
+                                              uint32_t inputCount, const uint32_t* inputs,
+                                              uint32_t outputCount, const uint32_t* outputs)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
+
+ResultCode ANeuralNetworksModel_finish(ANeuralNetworksModel* model)
+{
+  return ANEURALNETWORKS_NO_ERROR;
+}
diff --git a/tools/nnapi_bindings/bindings/template/src/model.h b/tools/nnapi_bindings/bindings/template/src/model.h
new file mode 100644 (file)
index 0000000..8da8f74
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __MODEL_H__
+#define __MODEL_H__
+
+struct ANeuralNetworksModel
+{
+};
+
+#endif // __MODEL_H__