Skip to content

Commit f28a543

Browse files
authored
Merge pull request #7 from FabianThomsen/main
Make all non-bound functions inline
2 parents 35dd782 + 39bcb49 commit f28a543

File tree

6 files changed

+34
-30
lines changed

6 files changed

+34
-30
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.8)
2-
project(tensorflow_cpp VERSION 1.0.2 LANGUAGES CXX)
2+
project(tensorflow_cpp VERSION 1.0.3 LANGUAGES CXX)
33

44
find_package(ros_environment QUIET)
55
if(ros_environment_FOUND)

doc/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#---------------------------------------------------------------------------
66
# DOXYFILE_ENCODING = UTF-8
77
PROJECT_NAME = "tensorflow_cpp"
8-
PROJECT_NUMBER = 1.0.2
8+
PROJECT_NUMBER = 1.0.3
99
# PROJECT_BRIEF =
1010
# PROJECT_LOGO =
1111
# OUTPUT_DIRECTORY =

include/tensorflow_cpp/graph_utils.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace tf = tensorflow;
5050
*
5151
* @return tf::GraphDef graph
5252
*/
53-
tf::GraphDef loadFrozenGraph(const std::string& file) {
53+
inline tf::GraphDef loadFrozenGraph(const std::string& file) {
5454

5555
tf::GraphDef graph_def;
5656
tf::Status status = tf::ReadBinaryProto(tf::Env::Default(), file, &graph_def);
@@ -71,7 +71,8 @@ tf::GraphDef loadFrozenGraph(const std::string& file) {
7171
* @return true if operation succeeded
7272
* @return false if operation failed
7373
*/
74-
bool loadGraphIntoSession(tf::Session* session, const tf::GraphDef& graph_def) {
74+
inline bool loadGraphIntoSession(tf::Session* session,
75+
const tf::GraphDef& graph_def) {
7576

7677
tf::Status status = session->Create(graph_def);
7778
if (!status.ok())
@@ -93,7 +94,7 @@ bool loadGraphIntoSession(tf::Session* session, const tf::GraphDef& graph_def) {
9394
*
9495
* @return tf::Session* session
9596
*/
96-
tf::Session* loadFrozenGraphIntoNewSession(
97+
inline tf::Session* loadFrozenGraphIntoNewSession(
9798
const std::string& file, const bool allow_growth = true,
9899
const double per_process_gpu_memory_fraction = 0,
99100
const std::string& visible_device_list = "") {
@@ -114,7 +115,8 @@ tf::Session* loadFrozenGraphIntoNewSession(
114115
*
115116
* @return std::vector<std::string> list of input node names
116117
*/
117-
std::vector<std::string> getGraphInputNames(const tf::GraphDef& graph_def) {
118+
inline std::vector<std::string> getGraphInputNames(
119+
const tf::GraphDef& graph_def) {
118120

119121
std::vector<std::string> input_nodes;
120122
for (const tf::NodeDef& node : graph_def.node()) {
@@ -132,7 +134,8 @@ std::vector<std::string> getGraphInputNames(const tf::GraphDef& graph_def) {
132134
*
133135
* @return std::vector<std::string> list of output node names
134136
*/
135-
std::vector<std::string> getGraphOutputNames(const tf::GraphDef& graph_def) {
137+
inline std::vector<std::string> getGraphOutputNames(
138+
const tf::GraphDef& graph_def) {
136139

137140
std::vector<std::string> output_nodes;
138141
std::vector<std::string> nodes_with_outputs;
@@ -161,8 +164,8 @@ std::vector<std::string> getGraphOutputNames(const tf::GraphDef& graph_def) {
161164
*
162165
* @return std::vector<int> node shape
163166
*/
164-
std::vector<int> getGraphNodeShape(const tf::GraphDef& graph_def,
165-
const std::string& node_name) {
167+
inline std::vector<int> getGraphNodeShape(const tf::GraphDef& graph_def,
168+
const std::string& node_name) {
166169

167170
std::vector<int> node_shape;
168171
for (const tf::NodeDef& node : graph_def.node()) {
@@ -187,8 +190,8 @@ std::vector<int> getGraphNodeShape(const tf::GraphDef& graph_def,
187190
*
188191
* @return tf::DataType node datatype
189192
*/
190-
tf::DataType getGraphNodeType(const tf::GraphDef& graph_def,
191-
const std::string& node_name) {
193+
inline tf::DataType getGraphNodeType(const tf::GraphDef& graph_def,
194+
const std::string& node_name) {
192195

193196
tf::DataType type = tf::DT_INVALID;
194197
for (const tf::NodeDef& node : graph_def.node()) {
@@ -214,7 +217,7 @@ tf::DataType getGraphNodeType(const tf::GraphDef& graph_def,
214217
*
215218
* @return std::string formatted info message
216219
*/
217-
std::string getGraphInfoString(const tf::GraphDef& graph_def) {
220+
inline std::string getGraphInfoString(const tf::GraphDef& graph_def) {
218221

219222
std::stringstream ss;
220223
ss << "FrozenGraph Info:" << std::endl;
@@ -252,4 +255,4 @@ std::string getGraphInfoString(const tf::GraphDef& graph_def) {
252255
}
253256

254257

255-
} // namespace tensorflow_cpp
258+
} // namespace tensorflow_cpp

include/tensorflow_cpp/saved_model_utils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace tf = tensorflow;
5454
*
5555
* @return tf::SavedModelBundleLite SavedModel
5656
*/
57-
tf::SavedModelBundleLite loadSavedModel(
57+
inline tf::SavedModelBundleLite loadSavedModel(
5858
const std::string& dir, const bool allow_growth = true,
5959
const double per_process_gpu_memory_fraction = 0,
6060
const std::string& visible_device_list = "") {
@@ -82,7 +82,7 @@ tf::SavedModelBundleLite loadSavedModel(
8282
*
8383
* @return tf::Session* session
8484
*/
85-
tf::Session* loadSavedModelIntoNewSession(
85+
inline tf::Session* loadSavedModelIntoNewSession(
8686
const std::string& dir, const bool allow_growth = true,
8787
const double per_process_gpu_memory_fraction = 0,
8888
const std::string& visible_device_list = "") {
@@ -102,7 +102,7 @@ tf::Session* loadSavedModelIntoNewSession(
102102
*
103103
* @return tf::Session* session
104104
*/
105-
tf::Session* getSessionFromSavedModel(
105+
inline tf::Session* getSessionFromSavedModel(
106106
const tf::SavedModelBundleLite& saved_model) {
107107

108108
return saved_model.GetSession();
@@ -121,7 +121,7 @@ tf::Session* getSessionFromSavedModel(
121121
*
122122
* @return std::string node name
123123
*/
124-
std::string getSavedModelNodeByLayerName(
124+
inline std::string getSavedModelNodeByLayerName(
125125
const tf::SavedModelBundleLite& saved_model, const std::string& layer_name,
126126
const std::string& signature = "serving_default") {
127127

@@ -156,7 +156,7 @@ std::string getSavedModelNodeByLayerName(
156156
*
157157
* @return std::string layer name
158158
*/
159-
std::string getSavedModelLayerByNodeName(
159+
inline std::string getSavedModelLayerByNodeName(
160160
const tf::SavedModelBundleLite& saved_model, const std::string& node_name,
161161
const std::string& signature = "serving_default") {
162162

@@ -195,7 +195,7 @@ std::string getSavedModelLayerByNodeName(
195195
*
196196
* @return std::vector<std::string> input names
197197
*/
198-
std::vector<std::string> getSavedModelInputNames(
198+
inline std::vector<std::string> getSavedModelInputNames(
199199
const tf::SavedModelBundleLite& saved_model, const bool layer_names = false,
200200
const std::string& signature = "serving_default") {
201201

@@ -236,7 +236,7 @@ std::vector<std::string> getSavedModelInputNames(
236236
*
237237
* @return std::vector<std::string> output names
238238
*/
239-
std::vector<std::string> getSavedModelOutputNames(
239+
inline std::vector<std::string> getSavedModelOutputNames(
240240
const tf::SavedModelBundleLite& saved_model, const bool layer_names = false,
241241
const std::string& signature = "serving_default") {
242242

@@ -270,7 +270,7 @@ std::vector<std::string> getSavedModelOutputNames(
270270
*
271271
* @return std::vector<int> node shape
272272
*/
273-
std::vector<int> getSavedModelNodeShape(
273+
inline std::vector<int> getSavedModelNodeShape(
274274
const tf::SavedModelBundleLite& saved_model, const std::string& node_name,
275275
const std::string& signature = "serving_default") {
276276

@@ -304,7 +304,7 @@ std::vector<int> getSavedModelNodeShape(
304304
*
305305
* @return tf::DataType node datatype
306306
*/
307-
tf::DataType getSavedModelNodeType(
307+
inline tf::DataType getSavedModelNodeType(
308308
const tf::SavedModelBundleLite& saved_model, const std::string& node_name,
309309
const std::string& signature = "serving_default") {
310310

@@ -337,7 +337,7 @@ tf::DataType getSavedModelNodeType(
337337
*
338338
* @return std::string formatted info message
339339
*/
340-
std::string getSavedModelInfoString(
340+
inline std::string getSavedModelInfoString(
341341
const tf::SavedModelBundleLite& saved_model) {
342342

343343
std::stringstream ss;
@@ -379,4 +379,4 @@ std::string getSavedModelInfoString(
379379
}
380380

381381

382-
} // namespace tensorflow_cpp
382+
} // namespace tensorflow_cpp

include/tensorflow_cpp/utils.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace tf = tensorflow;
4949
*
5050
* @return tf::SessionOptions session options
5151
*/
52-
tf::SessionOptions makeSessionOptions(
52+
inline tf::SessionOptions makeSessionOptions(
5353
const bool allow_growth = true,
5454
const double per_process_gpu_memory_fraction = 0,
5555
const std::string& visible_device_list = "") {
@@ -75,9 +75,10 @@ tf::SessionOptions makeSessionOptions(
7575
*
7676
* @return tf::Session* session
7777
*/
78-
tf::Session* createSession(const bool allow_growth = true,
79-
const double per_process_gpu_memory_fraction = 0,
80-
const std::string& visible_device_list = "") {
78+
inline tf::Session* createSession(
79+
const bool allow_growth = true,
80+
const double per_process_gpu_memory_fraction = 0,
81+
const std::string& visible_device_list = "") {
8182

8283
tf::Session* session;
8384
tf::SessionOptions options = makeSessionOptions(
@@ -91,4 +92,4 @@ tf::Session* createSession(const bool allow_growth = true,
9192
}
9293

9394

94-
} // namespace tensorflow_cpp
95+
} // namespace tensorflow_cpp

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package format="3">
33

44
<name>tensorflow_cpp</name>
5-
<version>1.0.2</version>
5+
<version>1.0.3</version>
66
<description>Wrappers around the TensorFlow C++ API for easy usage in ROS</description>
77

88
<maintainer email="[email protected]">Lennart Reiher</maintainer>

0 commit comments

Comments
 (0)