[custom op] Add basic custom op example structure (#7308)
authorVladimir Plazun/AI Tools Lab /SRR/Engineer/삼성전자 <v.plazun@samsung.com>
Mon, 9 Sep 2019 10:34:18 +0000 (13:34 +0300)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Mon, 9 Sep 2019 10:34:18 +0000 (19:34 +0900)
* [custom op] Add basic custom op example structure

Add directories and CMakeLists for apps and kernels

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
* use add_subdirectories

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
tests/CMakeLists.txt
tests/custom_op/CMakeLists.txt [new file with mode: 0644]
tests/custom_op/apps/CMakeLists.txt [new file with mode: 0644]
tests/custom_op/kernels/CMakeLists.txt [new file with mode: 0644]

index 23d09d1..96b610a 100644 (file)
@@ -1,2 +1,3 @@
 add_subdirectory(nnapi)
 add_subdirectory(tools)
+add_subdirectory(custom_op)
diff --git a/tests/custom_op/CMakeLists.txt b/tests/custom_op/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e37b54c
--- /dev/null
@@ -0,0 +1,2 @@
+add_subdirectory(apps)
+add_subdirectory(kernels)
diff --git a/tests/custom_op/apps/CMakeLists.txt b/tests/custom_op/apps/CMakeLists.txt
new file mode 100644 (file)
index 0000000..18eef3f
--- /dev/null
@@ -0,0 +1,20 @@
+if(NOT BUILD_NEURUN)
+    return()
+endif(NOT BUILD_NEURUN)
+
+# Takes target name, source list and kernel list
+function(add_nnfw_custom_op_app NAME)
+    cmake_parse_arguments(
+            PARSED_ARGS # prefix of output variables
+            "" # list of names of the boolean arguments (only defined ones will be true)
+            "" # list of names of mono-valued arguments
+            "SOURCES;KERNELS" # list of names of multi-valued arguments (output variables are lists)
+            ${ARGN} # arguments of the function to parse, here we take the all original ones
+    )
+    add_executable(${NAME} ${PARSED_ARGS_SOURCES})
+    target_link_libraries(${NAME} PRIVATE ${PARSED_ARGS_KERNELS})
+    target_link_libraries(${NAME} PRIVATE nnfw-dev)
+    target_link_libraries(${NAME} PRIVATE dl ${LIB_PTHREAD})
+endfunction()
+
+add_subdirectories()
diff --git a/tests/custom_op/kernels/CMakeLists.txt b/tests/custom_op/kernels/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9b960a3
--- /dev/null
@@ -0,0 +1,9 @@
+nnfw_find_package(FlatBuffers REQUIRED)
+
+function(add_nnfw_kernel NAME)
+    add_library(${NAME} STATIC ${ARGN})
+    target_link_libraries(${NAME} PRIVATE nnfw-dev)
+    target_link_libraries(${NAME} PRIVATE flatbuffers)
+endfunction()
+
+add_subdirectories()