Skip to content

Commit 7ee3752

Browse files
author
Shrestha Malik
committed
Merge remote-tracking branch 'origin/master' into shrestha/tag_rc3
2 parents 64e85a3 + 36107db commit 7ee3752

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2220
-1056
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ if (NOT USE_PRE_BUILT_NGRAPH)
275275
endif()
276276
set(NGRAPH_INSTALL_DIR ${NGRAPH_ARTIFACTS_DIR})
277277

278+
if(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
279+
add_definitions(-DNGRAPH_BRIDGE_STATIC_LIB_ENABLE)
280+
endif()
278281

279282
if(OS_VERSION STREQUAL "\"centos\"")
280283
set(LIB "lib64")

bazel/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ cc_library(
134134
"-Wno-strict-overflow",
135135
'-D NGRAPH_BRIDGE_STATIC_LIB_ENABLE',
136136
'-D NGRAPH_TF_USE_GRAPPLER_OPTIMIZER',
137+
'-D NGRAPH_CPU_STATIC_LIB_ENABLE',
137138
"-I ngraph_bridge",
138139
"-I logging",
139140
"-I external/ngraph/src",

bazel/ngraph.BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ cc_library(
166166
"src/ngraph/runtime/cpu/builder/convert.cpp",
167167
"src/ngraph/runtime/cpu/builder/convert_layout.cpp",
168168
"src/ngraph/runtime/cpu/builder/convolution.cpp",
169+
"src/ngraph/runtime/cpu/builder/cum_sum.cpp",
169170
"src/ngraph/runtime/cpu/builder/dot.cpp",
170171
"src/ngraph/runtime/cpu/builder/dropout.cpp",
171172
"src/ngraph/runtime/cpu/builder/embedding_lookup.cpp",

build_ngtf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ def main():
412412

413413
if (arguments.use_ngraph_staticlibs):
414414
ngraph_tf_cmake_flags.extend(["-DNGRAPH_BRIDGE_STATIC_LIB_ENABLE=TRUE"])
415+
415416
if (arguments.debug_build):
416417
ngraph_tf_cmake_flags.extend(["-DCMAKE_BUILD_TYPE=Debug"])
417418

examples/cpp/hello_tf.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@
3535
using namespace std;
3636

3737
// Prints the available backends
38-
void PrintAvailableBackends() {
38+
int PrintAvailableBackends() {
3939
// Get the list of backends
4040
auto supported_backends =
4141
tensorflow::ngraph_bridge::BackendManager::GetSupportedBackendNames();
4242
vector<string> backends(supported_backends.begin(), supported_backends.end());
43-
44-
cout << "Available backends: " << endl;
43+
if (backends.empty()) {
44+
std::cout << "No backend available " << std::endl;
45+
return -1;
46+
}
47+
std::cout << "Available backends: " << std::endl;
4548
for (auto& backend_name : backends) {
46-
cout << "Backend: " << backend_name << std::endl;
49+
std::cout << "Backend: " << backend_name << std::endl;
4750
}
51+
return 0;
4852
}
4953

5054
// Create a simple computation graph and run
@@ -116,13 +120,18 @@ void PrintVersion() {
116120
? std::string("Yes")
117121
: std::string("No"))
118122
<< std::endl;
119-
120-
PrintAvailableBackends();
123+
std::cout << std::endl;
121124
}
122125

123126
int main(int argc, char** argv) {
124127
PrintVersion();
125128

129+
// Print the avialable backends and if none are available
130+
// error out
131+
if (PrintAvailableBackends()) {
132+
return -1;
133+
}
134+
126135
// Run a simple example
127136
RunSimpleNetworkExample();
128137

examples/cpp/inference/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ if (APPLE)
6161
add_definitions(-DTEST_SINGLE_INSTANCE)
6262
endif()
6363

64+
if(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
65+
add_definitions(-DNGRAPH_BRIDGE_STATIC_LIB_ENABLE)
66+
endif()
67+
6468
if(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
6569
target_link_libraries(${APP_NAME}
6670
-Wl,--whole-archive

examples/cpp/inference/infer_multiple_networks.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ int main(int argc, char** argv) {
164164
return -1;
165165
}
166166

167+
// Register cpu backend for static linking
168+
// [TODO]: Revisit this to see if we can remove registering here and register
169+
// only in BackendManager.
170+
#if defined(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
171+
ngraph_register_cpu_backend();
172+
#endif
173+
167174
const char* backend = "CPU";
168175
if (SetNGraphBackend(backend) != tf::Status::OK()) {
169176
std::cout << "Error: Cannot set the backend: " << backend << std::endl;

examples/cpp/inference/infer_single_network.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ int main(int argc, char** argv) {
160160
return -1;
161161
}
162162

163+
// Register cpu backend for static linking
164+
#if defined(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
165+
ngraph_register_cpu_backend();
166+
#endif
167+
163168
const char* backend = "CPU";
164169
if (SetNGraphBackend(backend) != tf::Status::OK()) {
165170
std::cout << "Error: Cannot set the backend: " << backend << std::endl;

ngraph_bridge/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ if(NGRAPH_TF_ENABLE_VARIABLES_AND_OPTIMIZERS)
9898
add_definitions(-DNGRAPH_TF_ENABLE_VARIABLES_AND_OPTIMIZERS)
9999
endif()
100100

101+
if(NGRAPH_BRIDGE_STATIC_LIB_ENABLE)
102+
add_definitions(-DNGRAPH_BRIDGE_STATIC_LIB_ENABLE)
103+
endif()
104+
105+
if(NGRAPH_CPU_STATIC_LIB_ENABLE)
106+
add_definitions(-DNGRAPH_CPU_STATIC_LIB_ENABLE)
107+
endif()
108+
109+
if(NGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
110+
add_definitions(-DNGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
111+
endif()
112+
101113

102114
if(NGRAPH_TF_USE_GRAPPLER_OPTIMIZER)
103115
list(REMOVE_ITEM SRC ngraph_rewrite_pass.cc)

ngraph_bridge/enable_variable_ops/ngraph_rewrite_pass.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ class NGraphEncapsulationPass : public NGraphRewritePass {
226226

227227
// 4. Encapsulate clusters then, if requested, dump the graphs.
228228
FunctionDefLibrary* fdeflib_new = new FunctionDefLibrary();
229-
TF_RETURN_IF_ERROR(EncapsulateClusters(options.graph->get(), idx,
230-
fdeflib_new, config_map, {0, {}}));
229+
auto status = EncapsulateClusters(options.graph->get(), idx, fdeflib_new,
230+
config_map, {0, {}});
231+
if (status != Status::OK()) {
232+
delete (fdeflib_new);
233+
return status;
234+
}
231235
// TODO: not using fdeflib_new in this path. Only grappler path uses it
232236
free(fdeflib_new);
233237
if (DumpEncapsulatedGraphs()) {

0 commit comments

Comments
 (0)