[mio-tf] TensorFlow model library (#8274)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Fri, 18 Oct 2019 02:20:46 +0000 (11:20 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 18 Oct 2019 02:20:46 +0000 (11:20 +0900)
* [mio-tf] TensorFlow model library

This will introduce mio-tf as a separate project for accessing TensorFlow protobuf model file

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
* merge cmake and apply comments

compiler/mio-tf/CMakeLists.txt [new file with mode: 0644]
compiler/mio-tf/README.md [new file with mode: 0644]
compiler/mio-tf/src/mio_tf.test.cpp [new file with mode: 0644]

diff --git a/compiler/mio-tf/CMakeLists.txt b/compiler/mio-tf/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d670f6b
--- /dev/null
@@ -0,0 +1,48 @@
+nnas_find_package(Protobuf QUIET)
+# TensorFlowSource package is used to use ~.proto files
+nnas_find_package(TensorFlowSource EXACT 1.12 QUIET)
+
+if(NOT Protobuf_FOUND)
+  return()
+endif(NOT Protobuf_FOUND)
+
+if(NOT TensorFlowSource_FOUND)
+  return()
+endif(NOT TensorFlowSource_FOUND)
+
+message(STATUS "Build mio-tf: TRUE")
+
+# Minimal Protocol Buffer specification for GraphDef file (.pb) encoding/decoding
+unset(PROTO_FILES)
+list(APPEND PROTO_FILES tensorflow/core/framework/versions.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/resource_handle.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/types.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/tensor.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/tensor_shape.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/attr_value.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/op_def.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/node_def.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/function.proto)
+list(APPEND PROTO_FILES tensorflow/core/framework/graph.proto)
+
+Protobuf_Generate(GRAPHDEF_PROTO
+                  "${CMAKE_CURRENT_BINARY_DIR}/generated"
+                  "${TensorFlowSource_DIR}"
+                  ${PROTO_FILES})
+
+add_library(mio_tf STATIC ${GRAPHDEF_PROTO_SOURCES})
+set_target_properties(mio_tf PROPERTIES POSITION_INDEPENDENT_CODE ON)
+target_include_directories(mio_tf PUBLIC ${GRAPHDEF_PROTO_INCLUDE_DIRS})
+target_link_libraries(mio_tf PUBLIC ${GRAPHDEF_PROTO_LIBRARIES})
+
+if(NOT ENABLE_TEST)
+  return()
+endif(NOT ENABLE_TEST)
+
+nnas_find_package(GTest REQUIRED)
+
+file(GLOB_RECURSE TESTS "src/*.test.cpp")
+
+GTest_AddTest(mio_tf_test ${TESTS})
+target_include_directories(mio_tf_test PRIVATE src)
+target_link_libraries(mio_tf_test mio_tf)
diff --git a/compiler/mio-tf/README.md b/compiler/mio-tf/README.md
new file mode 100644 (file)
index 0000000..18f475a
--- /dev/null
@@ -0,0 +1,3 @@
+# mio-tf
+
+_mio-tf_ provides a library to access TensorFlow model files
diff --git a/compiler/mio-tf/src/mio_tf.test.cpp b/compiler/mio-tf/src/mio_tf.test.cpp
new file mode 100644 (file)
index 0000000..013dc2d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tensorflow/core/framework/graph.pb.h>
+
+#include <gtest/gtest.h>
+
+TEST(MIO_TF_Test, instance)
+{
+  tensorflow::GraphDef gd;
+  tensorflow::NodeDef nd;
+
+  SUCCEED();
+}