Introduce libtensorflow_graphdef
authorJonghyun Park <jh1302.park@samsung.com>
Tue, 6 Mar 2018 08:12:01 +0000 (17:12 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 7 Mar 2018 01:55:02 +0000 (10:55 +0900)
This commit introduces tensorflow_graphdef library which allows us to access
saved tensorflow graph definition.

Note that this library is disabled by default.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
externals/CMakeLists.txt

index b973337..b383236 100644 (file)
@@ -16,6 +16,35 @@ set(TENSORFLOW_BASE ${CMAKE_CURRENT_SOURCE_DIR}/tensorflow)
 set(TENSORFLOW_LITE_BASE ${TENSORFLOW_BASE}/tensorflow/contrib/lite)
 
 #
+# TensorFlow Graph Definition Accessor
+#
+if(ENABLE_TENSORFLOW_GRAPHDEF)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/versions)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/function)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/types)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/tensor)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/tensor_shape)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/attr_value)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/resource_handle)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/op_def)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/node_def)
+  list(APPEND TF_GRAPH_PROTO_TAGS tensorflow/core/framework/graph)
+
+  set(TF_GRAPH_PROTO_GENERATED ${CMAKE_CURRENT_BINARY_DIR}/generated)
+
+  foreach(TF_GRAPH_PROTO_TAG ${TF_GRAPH_PROTO_TAGS})
+    add_custom_command(OUTPUT "${TF_GRAPH_PROTO_GENERATED}/${TF_GRAPH_PROTO_TAG}.pb.cc"
+                       COMMAND mkdir -p "${TF_GRAPH_PROTO_GENERATED}"
+                       COMMAND protoc --proto_path=${TENSORFLOW_BASE} --cpp_out=${TF_GRAPH_PROTO_GENERATED} "${TF_GRAPH_PROTO_TAG}.proto")
+
+    list(APPEND TF_GRAPH_PROTO_SRCS "${TF_GRAPH_PROTO_GENERATED}/${TF_GRAPH_PROTO_TAG}.pb.cc")
+  endforeach()
+
+  add_library(tensorflow_graphdef ${TF_GRAPH_PROTO_SRCS})
+  target_include_directories(tensorflow_graphdef PUBLIC ${TF_GRAPH_PROTO_GENERATED})
+endif(ENABLE_TENSORFLOW_GRAPHDEF)
+
+#
 # Tensorflow Lite library
 #
 file(GLOB TFLITE_CORE_SRCS "${TENSORFLOW_LITE_BASE}/*.c" "${TENSORFLOW_LITE_BASE}/*.cc")