--- /dev/null
+nncc_find_package(Protobuf QUIET)
+nncc_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 tfkit: 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(TENSORFLOW_GRAPHDEF_PROTO
+ "${CMAKE_CURRENT_BINARY_DIR}/generated"
+ "${TensorFlowSource_DIR}"
+ ${PROTO_FILES})
+
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+
+add_library(tfkitproto STATIC ${TENSORFLOW_GRAPHDEF_PROTO_SOURCES})
+set_target_properties(tfkitproto PROPERTIES POSITION_INDEPENDENT_CODE ON)
+target_include_directories(tfkitproto PUBLIC ${TENSORFLOW_GRAPHDEF_PROTO_INCLUDE_DIRS})
+target_link_libraries(tfkitproto PUBLIC libprotobuf)
+
+add_executable(tfkit ${SOURCES})
+target_link_libraries(tfkit PRIVATE stdex)
+target_link_libraries(tfkit PRIVATE cli)
+target_link_libraries(tfkit PRIVATE tfkitproto)
+target_link_libraries(tfkit PRIVATE nncc_common)
--- /dev/null
+/*
+ * 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 "DecodeCommand.hpp"
+
+#include <tensorflow/core/framework/graph.pb.h>
+
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+
+#include <iostream>
+
+int DecodeCommand::run(int, const char *const *) const
+{
+ tensorflow::GraphDef graph_def;
+
+ // Load binary from standard input
+ google::protobuf::io::IstreamInputStream is{&std::cin};
+ google::protobuf::io::CodedInputStream coded_is{&is};
+
+ if (!graph_def.ParseFromCodedStream(&coded_is))
+ {
+ std::cerr << "ERROR: Failed to parse tensorflow model" << std::endl;
+ return 255;
+ }
+
+ // Write text into standard output
+ google::protobuf::io::OstreamOutputStream os{&std::cout};
+ google::protobuf::TextFormat::Print(graph_def, &os);
+
+ return 0;
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __DECODE_COMMAND_H__
+#define __DECODE_COMMAND_H__
+
+#include <cli/Command.h>
+
+struct DecodeCommand final : public cli::Command
+{
+ int run(int argc, const char *const *argv) const override;
+};
+
+#endif // __DECODE_COMMAND_H__
--- /dev/null
+/*
+ * 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 "DecodeCommand.hpp"
+
+#include <cli/App.h>
+#include <stdex/Memory.h>
+
+int main(int argc, char **argv)
+{
+ cli::App app{argv[0]};
+
+ app.insert("decode", stdex::make_unique<DecodeCommand>());
+
+ return app.run(argc - 1, argv + 1);
+}