diff --git a/CMakeLists.txt b/CMakeLists.txt index 28e0f3a4e..d42737b93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,11 @@ include(ExternalProject) include(CMakeDependentOption) include(cmake/sdl.cmake) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-comment -Wno-sign-compare") +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-comment -Wno-sign-compare -Wno-backslash-newline-escape") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-comment -Wno-sign-compare") +endif() # In order to compile ngraph-tf with memory leak detection, run `cmake` with `-DCMAKE_BUILD_TYPE=Sanitize`. # N.B.: This *will* crash python unit tests because ngraph-tf will be loaded "too late" via `dlopen`, diff --git a/bazel/BUILD b/bazel/BUILD index b7853ff56..c701790b0 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -101,6 +101,10 @@ cc_library( "-pthread", "-std=c++11", "-D_FORTIFY_SOURCE=2", + "-Wall", + "-Wextra", + "-Wno-comment", + "-Wno-sign-compare", "-Wformat", "-Wformat-security", "-fstack-protector-all", @@ -146,3 +150,34 @@ tf_cc_binary( linkstatic=True, visibility = ["//visibility:public"], ) + +tf_cc_binary( + name = 'infer_multi', + srcs = [ + "examples/cpp/infer_multiple_networks/main.cc", + "examples/cpp/infer_multiple_networks/inference_engine.h", + "examples/cpp/infer_multiple_networks/inference_engine.cc", + "examples/cpp/tf_label_image_utils.cc", + ], + deps = [ + "@org_tensorflow//tensorflow/cc:cc_ops", + "@org_tensorflow//tensorflow/cc:client_session", + "@org_tensorflow//tensorflow/core:tensorflow", + ":ngraph_bridge_lib", + "@ngraph//:cpu_backend", + ], + copts = [ + "-pthread", + "-std=c++11", + "-D_FORTIFY_SOURCE=2", + "-Wformat", + "-Wformat-security", + "-Wformat", + "-fstack-protector-all", + "-I ngraph_bridge", + "-I external/ngraph/src", + "-I logging", + ] + CXX_ABI, + linkstatic=False, + visibility = ["//visibility:public"], +) diff --git a/examples/cpp/infer_multiple_networks/BUILD b/examples/cpp/infer_multiple_networks/BUILD deleted file mode 100644 index 8ddf49dc8..000000000 --- a/examples/cpp/infer_multiple_networks/BUILD +++ /dev/null @@ -1,33 +0,0 @@ -load("//:cxx_abi_option.bzl", "CXX_ABI") -load("@org_tensorflow//tensorflow:tensorflow.bzl", "tf_cc_binary") - -tf_cc_binary( - name = 'infer_multi', - srcs = [ - "main.cc", - "inference_engine.h", - "inference_engine.cc", - "tf_label_image_utils.cc" - ], - deps = [ - "@org_tensorflow//tensorflow/cc:cc_ops", - "@org_tensorflow//tensorflow/cc:client_session", - "@org_tensorflow//tensorflow/core:tensorflow", - "//:ngraph_bridge_lib", - "@ngraph//:cpu_backend", - ], - copts = [ - "-pthread", - "-std=c++11", - "-D_FORTIFY_SOURCE=2", - "-Wformat", - "-Wformat-security", - "-Wformat", - "-fstack-protector-all", - "-I ngraph_bridge", - "-I external/ngraph/src", - "-I logging", - ] + CXX_ABI, - linkstatic=False, - visibility = ["//visibility:public"], -) \ No newline at end of file diff --git a/examples/cpp/infer_multiple_networks/inference_engine.cc b/examples/cpp/infer_multiple_networks/inference_engine.cc index 0c7df4ed2..f6c5f8384 100644 --- a/examples/cpp/infer_multiple_networks/inference_engine.cc +++ b/examples/cpp/infer_multiple_networks/inference_engine.cc @@ -51,8 +51,8 @@ extern tf::Status ReadTensorFromImageFile(const std::vector& file_names, namespace infer_multiple_networks { -InferenceEngine::InferenceEngine(const string& name, const string& backend) - : m_name(name) {} +InferenceEngine::InferenceEngine(const string& name) : m_name(name) {} + Status InferenceEngine::Load(const string& network, const std::vector& image_files, int input_width, int input_height, diff --git a/examples/cpp/infer_multiple_networks/inference_engine.h b/examples/cpp/infer_multiple_networks/inference_engine.h index 30d659702..420290b45 100644 --- a/examples/cpp/infer_multiple_networks/inference_engine.h +++ b/examples/cpp/infer_multiple_networks/inference_engine.h @@ -42,7 +42,7 @@ namespace infer_multiple_networks { class InferenceEngine { public: - InferenceEngine(const string& name, const string& backend); + InferenceEngine(const string& name); ~InferenceEngine(); Status Load(const string& network, const std::vector& image_files, diff --git a/examples/cpp/infer_multiple_networks/main.cc b/examples/cpp/infer_multiple_networks/main.cc index 622cd5156..07ab41393 100644 --- a/examples/cpp/infer_multiple_networks/main.cc +++ b/examples/cpp/infer_multiple_networks/main.cc @@ -151,42 +151,42 @@ int main(int argc, char** argv) { std::cout << "Component versions\n"; PrintVersion(); - infer_multiple_networks::InferenceEngine infer_engine_1("engine_1", "CPU:0"); + infer_multiple_networks::InferenceEngine infer_engine_1("engine_1"); TF_CHECK_OK(infer_engine_1.Load( graph, images, input_width, input_height, input_mean, input_std, input_layer, output_layer, use_NCHW, preload_images, input_channels)); - infer_multiple_networks::InferenceEngine infer_engine_2("engine_2", "CPU:0"); + infer_multiple_networks::InferenceEngine infer_engine_2("engine_2"); TF_CHECK_OK(infer_engine_2.Load( graph, images, input_width, input_height, input_mean, input_std, input_layer, output_layer, use_NCHW, preload_images, input_channels)); - infer_multiple_networks::InferenceEngine infer_engine_3("engine_3", "CPU:0"); + infer_multiple_networks::InferenceEngine infer_engine_3("engine_3"); TF_CHECK_OK(infer_engine_3.Load( graph, images, input_width, input_height, input_mean, input_std, input_layer, output_layer, use_NCHW, preload_images, input_channels)); bool engine_1_running = true; - infer_engine_1.Start([&](int step_count) { + TF_CHECK_OK(infer_engine_1.Start([&](int step_count) { if (step_count == (iteration_count - 1)) { - infer_engine_1.Stop(); + TF_CHECK_OK(infer_engine_1.Stop()); engine_1_running = false; } - }); + })); bool engine_2_running = true; - infer_engine_2.Start([&](int step_count) { + TF_CHECK_OK(infer_engine_2.Start([&](int step_count) { if (step_count == (iteration_count - 1)) { - infer_engine_2.Stop(); + TF_CHECK_OK(infer_engine_2.Stop()); engine_2_running = false; } - }); + })); bool engine_3_running = true; - infer_engine_3.Start([&](int step_count) { + TF_CHECK_OK(infer_engine_3.Start([&](int step_count) { if (step_count == (iteration_count - 1)) { - infer_engine_3.Stop(); + TF_CHECK_OK(infer_engine_3.Stop()); engine_3_running = false; } - }); + })); while (engine_1_running || engine_2_running || engine_3_running) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); diff --git a/examples/cpp/tf_label_image_utils.cc b/examples/cpp/tf_label_image_utils.cc index 00379f5f4..783a65627 100644 --- a/examples/cpp/tf_label_image_utils.cc +++ b/examples/cpp/tf_label_image_utils.cc @@ -172,15 +172,15 @@ Status ReadTensorFromImageFile(const std::vector& file_names, // Now try to figure out what kind of file it is and decode it. tensorflow::Output image_reader; - if (tensorflow::str_util::EndsWith(file_names[i], ".png")) { + if (absl::EndsWith(file_names[i], ".png")) { image_reader = DecodePng(root.WithOpName("png_reader"), file_reader, DecodePng::Channels(input_channels)); - } else if (tensorflow::str_util::EndsWith(file_names[i], ".gif")) { + } else if (absl::EndsWith(file_names[i], ".gif")) { // gif decoder returns 4-D tensor, remove the first dim image_reader = Squeeze(root.WithOpName("squeeze_first_dim"), DecodeGif(root.WithOpName("gif_reader"), file_reader)); - } else if (tensorflow::str_util::EndsWith(file_names[i], ".bmp")) { + } else if (absl::EndsWith(file_names[i], ".bmp")) { image_reader = DecodeBmp(root.WithOpName("bmp_reader"), file_reader); } else { // Assume if it's neither a PNG nor a GIF then it must be a JPEG. diff --git a/ngraph_bridge/enable_variable_ops/ngraph_tracked_variable.cc b/ngraph_bridge/enable_variable_ops/ngraph_tracked_variable.cc index f91bd278d..459bff98f 100644 --- a/ngraph_bridge/enable_variable_ops/ngraph_tracked_variable.cc +++ b/ngraph_bridge/enable_variable_ops/ngraph_tracked_variable.cc @@ -230,7 +230,7 @@ void NGraphVariableOp::Compute(OpKernelContext* ctx) { // conditional on whether any reader is taking in a reference. More // conservative condition that would work for now: invalidate if any // reader is not NGraphEncapsulateOp. - auto t_creator = [this](NGraphFreshnessTracker** tracker) { + auto t_creator = [](NGraphFreshnessTracker** tracker) { *tracker = new NGraphFreshnessTracker(); return Status::OK(); }; diff --git a/ngraph_bridge/enable_variable_ops/ngraph_var.h b/ngraph_bridge/enable_variable_ops/ngraph_var.h index cc0462c69..cdfeba5b3 100644 --- a/ngraph_bridge/enable_variable_ops/ngraph_var.h +++ b/ngraph_bridge/enable_variable_ops/ngraph_var.h @@ -56,7 +56,10 @@ class NGraphVar : public ResourceBase { // Create Backend NGRAPH_VLOG(4) << "NGraphVar::Create Backend "; - BackendManager::CreateBackend(ng_backend_name_); + Status status = BackendManager::CreateBackend(ng_backend_name_); + if (!status.ok()) { + NGRAPH_VLOG(2) << "Cannot create backend " << ng_backend_name_; + } ng::runtime::Backend* op_backend = BackendManager::GetBackend(ng_backend_name_); diff --git a/ngraph_bridge/ngraph_assign_clusters.cc b/ngraph_bridge/ngraph_assign_clusters.cc index d5da383f0..279a7a1c3 100644 --- a/ngraph_bridge/ngraph_assign_clusters.cc +++ b/ngraph_bridge/ngraph_assign_clusters.cc @@ -653,7 +653,7 @@ Status AssignClusters(Graph* graph) { continue; } - int cluster_idx = NGraphClusterManager::NewCluster(); + size_t cluster_idx = NGraphClusterManager::NewCluster(); for (auto node : cluster->nodes) { if (NGRAPH_VLOG_IS_ON(5)) { @@ -669,7 +669,7 @@ Status AssignClusters(Graph* graph) { } // TODO(amprocte): move attr name to a constant - node->AddAttr("_ngraph_cluster", cluster_idx); + node->AddAttr("_ngraph_cluster", (int)cluster_idx); if (config::IsLoggingPlacement()) { // map from cluster id to ngraph_cluster id @@ -798,7 +798,10 @@ Status AssignClusters(Graph* graph) { std::cout << "NGTF_SUMMARY: Summary of reasons why a pair of edge " "connected clusters did not merge\n"; print_reason_summary(reason_count_clusters, - [](EdgeNonContractionReasons x) { return false; }); + [](EdgeNonContractionReasons x) { + NGRAPH_VLOG(5) << "EdgeNonContractionReasons: " << x; + return false; + }); } return Status::OK(); diff --git a/ngraph_bridge/ngraph_builder.cc b/ngraph_bridge/ngraph_builder.cc index 27094c8e9..289f48a89 100644 --- a/ngraph_bridge/ngraph_builder.cc +++ b/ngraph_bridge/ngraph_builder.cc @@ -166,8 +166,7 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const Node* op, } namespace detail { -static Status GetInputNodes(const Builder::OpMap& ng_op_map, const Node* op, - size_t index) { +static Status GetInputNodes(const Builder::OpMap&, const Node*, size_t) { return Status::OK(); } @@ -366,7 +365,7 @@ Builder::TF_NGRAPH_CONST_MAP() { // }); // } static Status TranslateUnaryOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map, std::function(std::shared_ptr)> create_unary_op) { @@ -422,7 +421,7 @@ static Status TranslateUnaryOp( // static Status TranslateBinaryOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map, std::function(std::shared_ptr, std::shared_ptr)> @@ -460,9 +459,10 @@ static Status TranslateBinaryOp( } // Helper function for translating QuantizedAvgPool and QuantizedMaxPool -static Status TranslateQuantizedPoolOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map, std::string pooling_name) { +static Status TranslateQuantizedPoolOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map, + std::string pooling_name) { bool is_quantizedAvgPool = pooling_name == "QuantizedAvgPool"; bool is_quantizedMaxPool = pooling_name == "QuantizedMaxPool"; @@ -533,9 +533,8 @@ static Status TranslateQuantizedPoolOp( return Status::OK(); } -static Status TranslateAddNOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateAddNOp(const Node* op, const std::vector&, + Builder::OpMap& ng_op_map) { std::vector> ng_arg_vec(op->num_inputs()); for (int inp_idx = 0; inp_idx < op->num_inputs(); inp_idx++) @@ -596,9 +595,9 @@ static Status TranslateArgMinMaxOp( return Status::OK(); } -static Status TranslateAvgPoolOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateAvgPoolOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -910,9 +909,9 @@ static Status TranslateBatchMatMulOp( return Status::OK(); } -static Status TranslateBiasAddOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateBiasAddOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_bias; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_bias)); @@ -959,9 +958,9 @@ static Status TranslateBiasAddOp( return Status::OK(); } -static Status TranslateBiasAddGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateBiasAddGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -1009,9 +1008,8 @@ static Status TranslateBiasAddGradOp( return Status::OK(); } -static Status TranslateCastOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateCastOp(const Node* op, const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -1156,9 +1154,9 @@ static Status TranslateConcatV2Op( return Status::OK(); } -static Status TranslateConstOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateConstOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { DataType dtype; TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dtype", &dtype)); @@ -1186,9 +1184,9 @@ static Status TranslateConstOp( return Status::OK(); } -static Status TranslateConv2DOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateConv2DOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_filter; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_filter)); @@ -1472,9 +1470,9 @@ static Status TranslateConv2DBackpropInputOp( } // Translate Conv3D Op -static Status TranslateConv3DOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateConv3DOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_filter; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_filter)); @@ -1547,9 +1545,9 @@ static Status TranslateConv3DOp( } // Translate DepthToSpace op -static Status TranslateDepthToSpaceOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateDepthToSpaceOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -1707,7 +1705,7 @@ static Status TranslateDepthToSpaceOp( } static Status TranslateDepthwiseConv2dNativeOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_filter; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_filter)); @@ -1995,9 +1993,9 @@ static Status TranslateFusedBatchNormOp( return Status::OK(); } -static Status TranslateFusedBatchNormGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateFusedBatchNormGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { bool is_v3 = op->type_string() == "FusedBatchNormGradV3"; TF_RETURN_IF_ERROR(ValidateInputCount(op, is_v3 ? 6 : 5)); @@ -2096,9 +2094,9 @@ static Status TranslateFusedBatchNormGradOp( return Status::OK(); } -static Status TranslateGatherNdOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateGatherNdOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_params; shared_ptr ng_indices; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_params, &ng_indices)); @@ -2127,9 +2125,9 @@ static Status TranslateGatherNdOp( return Status::OK(); } -static Status TranslateFusedMatMulOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateFusedMatMulOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { int num_args; TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num_args", &num_args)); @@ -2245,7 +2243,7 @@ static Status TranslateGatherV2Op( // Negative axis is supported. Accounting for that auto ng_input_shape = ng_input->get_shape(); size_t ng_input_rank = ng_input_shape.size(); - size_t axis; + int axis; if (tf_axis[0] >= 0) { axis = tf_axis[0]; } else { @@ -2268,9 +2266,9 @@ static Status TranslateGatherV2Op( return Status::OK(); } -static Status TranslateFusedConv2DOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateFusedConv2DOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { int num_args; TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num_args", &num_args)); @@ -2444,23 +2442,23 @@ static Status TranslateFusedConv2DOp( } } else { return errors::Unimplemented("Unsupported _FusedConv2D " + - str_util::Join(fused_ops, ",")); + absl::StrJoin(fused_ops, ",")); } return Status::OK(); } -static Status TranslateIdentityOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateIdentityOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_arg; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_arg)); SaveNgOp(ng_op_map, op->name(), ng_arg); return Status::OK(); } -static Status TranslateL2LossOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateL2LossOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -2485,9 +2483,9 @@ static Status TranslateL2LossOp( return Status::OK(); } -static Status TranslateLogSoftmaxOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateLogSoftmaxOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_inp; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_inp)); auto inp_shape = ng_inp->get_shape(); @@ -2513,9 +2511,9 @@ static Status TranslateLogSoftmaxOp( return Status::OK(); } -static Status TranslateSoftplusOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSoftplusOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_inp; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_inp)); auto ng_exp = ConstructNgNode(op->name(), ng_inp); @@ -2528,9 +2526,9 @@ static Status TranslateSoftplusOp( return Status::OK(); } -static Status TranslateMatMulOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateMatMulOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_lhs, ng_rhs; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_lhs, &ng_rhs)); @@ -2554,9 +2552,9 @@ static Status TranslateMatMulOp( return Status::OK(); } -static Status TranslateMaxPoolOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateMaxPoolOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -2616,9 +2614,9 @@ static Status TranslateMaxPoolOp( return Status::OK(); } -static Status TranslateMaxPool3DOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateMaxPool3DOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -2678,9 +2676,9 @@ static Status TranslateMaxPool3DOp( return Status::OK(); } -static Status TranslateMaxPoolGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateMaxPoolGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_grad, ng_fwd; TF_RETURN_IF_ERROR( GetInputNodes(ng_op_map, op, &ng_input, &ng_fwd, &ng_grad)); @@ -2943,9 +2941,8 @@ static Status TranslateOneHotOp( return Status::OK(); } -static Status TranslatePackOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslatePackOp(const Node* op, const std::vector&, + Builder::OpMap& ng_op_map) { TF_RETURN_IF_ERROR(ValidateInputCountMin(op, 1)); ng::NodeVector ng_concat_inputs; @@ -2971,14 +2968,14 @@ static Status TranslatePackOp( // if inputs shape is (2, 3, 4), and axis is 1, then we want // to create output_shape (2, num_inputs, 3, 4) for (size_t i = 0; i < input_rank; ++i) { - output_shape[(i < concat_axis) ? i : i + 1] = input_shape[i]; + output_shape[((int)i < concat_axis) ? i : i + 1] = input_shape[i]; } output_shape[concat_axis] = op->num_inputs(); ng::AxisVector ng_axis_order(input_rank); std::iota(ng_axis_order.begin(), ng_axis_order.end(), 0); - if (concat_axis == input_rank) { + if ((size_t)concat_axis == input_rank) { // need to add extra dimension before we concatenate // along it ng::Shape extended_shape = input_shape; @@ -3040,9 +3037,8 @@ static Status TranslatePadOp(const Node* op, return Status::OK(); } -static Status TranslateRankOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateRankOp(const Node* op, const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3399,7 +3395,7 @@ static Status TranslateQuantizedConv( template static Status TranslateQuantizedConv2DWithBiasMaybeReluAndRequantizeOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { auto create_quantized_conv_node = []( std::vector> node_inps, ng::Strides ng_strides, @@ -3415,7 +3411,7 @@ static Status TranslateQuantizedConv2DWithBiasMaybeReluAndRequantizeOp( } static Status TranslateQuantizedConv2DWithBiasSumAndReluAndRequantizeOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { auto create_quantized_conv_node = []( std::vector> node_inps, ng::Strides ng_strides, @@ -3431,7 +3427,7 @@ static Status TranslateQuantizedConv2DWithBiasSumAndReluAndRequantizeOp( } static Status TranslateQuantizedConv2DWithBiasSignedSumAndReluAndRequantizeOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { auto create_quantized_conv_node = []( std::vector> node_inps, ng::Strides ng_strides, @@ -3453,9 +3449,9 @@ static Status TranslateQuantizedMaxPoolOp( "QuantizedMaxPool"); } -static Status TranslateQuantizeV2Op( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateQuantizeV2Op(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_min, ng_max; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_min, &ng_max)); @@ -3479,9 +3475,9 @@ static Status TranslateQuantizeV2Op( return Status::OK(); } -static Status TranslateDequantizeOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateDequantizeOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_min, ng_max; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_min, &ng_max)); @@ -3492,9 +3488,9 @@ static Status TranslateDequantizeOp( return Status::OK(); } -static Status TranslateRelu6Op( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateRelu6Op(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3509,9 +3505,9 @@ static Status TranslateRelu6Op( return Status::OK(); } -static Status TranslateReluGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateReluGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_arg, ng_delta; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_delta, &ng_arg)); @@ -3606,9 +3602,9 @@ static Status TranslateRsqrtOp( }); } -static Status TranslateRsqrtGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateRsqrtGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; shared_ptr ng_delta; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_delta)); @@ -3637,9 +3633,9 @@ static Status TranslateRsqrtGradOp( return Status::OK(); } -static Status TranslateShapeOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateShapeOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3667,9 +3663,9 @@ static Status TranslateShapeOp( return Status::OK(); } -static Status TranslateSigmoidGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSigmoidGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; shared_ptr ng_delta; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_delta)); @@ -3685,9 +3681,9 @@ static Status TranslateSigmoidGradOp( return Status::OK(); } -static Status TranslateSigmoidOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSigmoidOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3705,9 +3701,8 @@ static Status TranslateSigmoidOp( return Status::OK(); } -static Status TranslateSizeOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSizeOp(const Node* op, const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3790,9 +3785,9 @@ static Status TranslateSliceOp( return Status::OK(); } -static Status TranslateSoftmaxOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSoftmaxOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3810,9 +3805,9 @@ static Status TranslateSoftmaxOp( } // Translate SpaceToDepthOp -static Status TranslateSpaceToDepthOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSpaceToDepthOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); @@ -3891,7 +3886,7 @@ static Status TranslateSpaceToDepthOp( } static Status TranslateSparseSoftmaxCrossEntropyWithLogitsOp( - const Node* op, const std::vector& static_input_map, + const Node* op, const std::vector&, Builder::OpMap& ng_op_map) { // TF op Inputs: // 1. Logits/Features: @@ -4143,9 +4138,9 @@ static Status TranslateSquaredDifferenceOp( }); } -static Status TranslateSqueezeOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSqueezeOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); size_t input_dims = ng_input->get_shape().size(); @@ -4324,7 +4319,7 @@ static Status TranslateStridedSliceOp( size_t ng_begin_idx, ng_end_idx; if (!shrink_mask) { - if (clamped_begin_idx == clamped_end_idx) { + if ((int)clamped_begin_idx == clamped_end_idx) { // Empty due to matching indexes ng_begin_idx = clamped_begin_idx; // Type safety: clamped_begin_idx == clamped_end_idx implies, @@ -4513,9 +4508,9 @@ static Status TranslateStridedSliceOp( // Computes the gradient for tanh of 'x' w.r.t its input // grad = dy * (1 - y * y) // where y = tanh(x) and dy is the corresponding input gradient -static Status TranslateTanhGradOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateTanhGradOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input, ng_delta; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input, &ng_delta)); @@ -4664,9 +4659,9 @@ static Status TranslateTransposeOp( return Status::OK(); } -static Status TranslateUnpackOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateUnpackOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { TF_RETURN_IF_ERROR(ValidateInputCount(op, 1)); shared_ptr ng_input; @@ -4688,7 +4683,7 @@ static Status TranslateUnpackOp( ng::Shape output_shape; for (size_t i = 0; i < input_rank; ++i) { - if (i != unpack_axis) { + if ((int)i != unpack_axis) { output_shape.push_back(input_shape[i]); } } @@ -4717,9 +4712,9 @@ static Status TranslateUnpackOp( return Status::OK(); } -static Status TranslateSelectOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateSelectOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input1, ng_input2, ng_input3; TF_RETURN_IF_ERROR( GetInputNodes(ng_op_map, op, &ng_input1, &ng_input2, &ng_input3)); @@ -4778,9 +4773,9 @@ static Status TranslateSelectOp( return Status::OK(); } -static Status TranslateZerosLikeOp( - const Node* op, const std::vector& static_input_map, - Builder::OpMap& ng_op_map) { +static Status TranslateZerosLikeOp(const Node* op, + const std::vector&, + Builder::OpMap& ng_op_map) { shared_ptr ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, &ng_input)); diff --git a/ngraph_bridge/ngraph_cluster_manager.cc b/ngraph_bridge/ngraph_cluster_manager.cc index e6fafc0d0..1d4603807 100644 --- a/ngraph_bridge/ngraph_cluster_manager.cc +++ b/ngraph_bridge/ngraph_cluster_manager.cc @@ -24,15 +24,15 @@ namespace ngraph_bridge { std::vector NGraphClusterManager::s_cluster_graphs; std::mutex NGraphClusterManager::s_cluster_graphs_mutex; -int NGraphClusterManager::NewCluster() { +size_t NGraphClusterManager::NewCluster() { std::lock_guard guard(s_cluster_graphs_mutex); - int new_idx = s_cluster_graphs.size(); + size_t new_idx = s_cluster_graphs.size(); s_cluster_graphs.push_back(new GraphDef()); return new_idx; } -GraphDef* NGraphClusterManager::GetClusterGraph(int idx) { +GraphDef* NGraphClusterManager::GetClusterGraph(size_t idx) { std::lock_guard guard(s_cluster_graphs_mutex); return idx < s_cluster_graphs.size() ? s_cluster_graphs[idx] : nullptr; } diff --git a/ngraph_bridge/ngraph_cluster_manager.h b/ngraph_bridge/ngraph_cluster_manager.h index 34ed38d50..acc0814d0 100644 --- a/ngraph_bridge/ngraph_cluster_manager.h +++ b/ngraph_bridge/ngraph_cluster_manager.h @@ -27,8 +27,8 @@ namespace ngraph_bridge { class NGraphClusterManager { public: - static int NewCluster(); - static tensorflow::GraphDef* GetClusterGraph(int idx); + static size_t NewCluster(); + static tensorflow::GraphDef* GetClusterGraph(size_t idx); static void EvictAllClusters(); private: diff --git a/ngraph_bridge/ngraph_encapsulate_clusters.cc b/ngraph_bridge/ngraph_encapsulate_clusters.cc index 022da98f3..48563c43f 100644 --- a/ngraph_bridge/ngraph_encapsulate_clusters.cc +++ b/ngraph_bridge/ngraph_encapsulate_clusters.cc @@ -791,8 +791,8 @@ Status EncapsulateClusters( "Caught exception while creating backend string ", exp.what(), "\n"); } - BackendManager::CreateBackend( - op_backend_name); // Created a backend here. must free it + TF_RETURN_IF_ERROR(BackendManager::CreateBackend( + op_backend_name)); // Created a backend here. must free it std::unordered_map additional_attribute_map; for (auto itr : node->attrs()) { // Find the optional attributes to be sent to the backend. @@ -816,6 +816,7 @@ Status EncapsulateClusters( try { op_backend = BackendManager::GetBackend(op_backend_name); } catch (const std::out_of_range& e) { + NGRAPH_VLOG(5) << "Exception: " << e.what(); BackendManager::ReleaseBackend(op_backend_name); throw; } diff --git a/ngraph_bridge/ngraph_encapsulate_impl.cc b/ngraph_bridge/ngraph_encapsulate_impl.cc index f7a767b73..721317348 100644 --- a/ngraph_bridge/ngraph_encapsulate_impl.cc +++ b/ngraph_bridge/ngraph_encapsulate_impl.cc @@ -343,10 +343,13 @@ Status NGraphEncapsulateImpl::AllocateNGInputTensors( input_copy_events.push_back(std::move(event_copy_input_next)); } catch (const std::exception& exp) { - errors::Internal( - "Caught exception while transferring tensor data to nGraph\n"); + return errors::Internal( + "Caught exception while transferring tensor data to nGraph. " + "Exception: ", + exp.what()); } catch (...) { - errors::Internal("Error in transferring tensor data to nGraph\n"); + return errors::Internal( + "Error in transferring tensor data to nGraph\n"); } } input_caches[i] = std::make_pair(current_src_ptr, current_ng_tensor); diff --git a/ngraph_bridge/ngraph_encapsulate_op.cc b/ngraph_bridge/ngraph_encapsulate_op.cc index 597fab0b1..60128b06f 100644 --- a/ngraph_bridge/ngraph_encapsulate_op.cc +++ b/ngraph_bridge/ngraph_encapsulate_op.cc @@ -99,7 +99,11 @@ NGraphEncapsulateOp::NGraphEncapsulateOp(OpKernelConstruction* ctx) const auto get_func_sig = [&flib](const string& op, const OpDef** sig) { return flib.LookUpOpDef(op, sig); }; - FunctionDefToBodyHelper(*fdef, {}, &flib, get_func_sig, &fnbody); + Status status = + FunctionDefToBodyHelper(*fdef, {}, &flib, get_func_sig, &fnbody); + if (!status.ok()) { + NGRAPH_VLOG(2) << "FunctionDefToBodyHelper returned a not ok status."; + } CopyGraph(*fnbody->graph, &ng_encap_impl.m_graph); } else { GraphConstructorOptions opts; @@ -186,7 +190,10 @@ NGraphEncapsulateOp::NGraphEncapsulateOp(OpKernelConstruction* ctx) OP_REQUIRES_OK(ctx, status); } NGRAPH_VLOG(4) << "NGraphEncapsulateOp::Create backend " << def().name(); - BackendManager::CreateBackend(ng_encap_impl.GetOpBackend()); + Status status = BackendManager::CreateBackend(ng_encap_impl.GetOpBackend()); + if (!status.ok()) { + NGRAPH_VLOG(2) << "Cannot create backend " << ng_encap_impl.GetOpBackend(); + } // SetConfig will be called for each EncapsulateOp BackendManager::SetConfig(ng_encap_impl.GetOpBackend(), additional_attribute_map); diff --git a/ngraph_bridge/ngraph_mark_for_clustering.cc b/ngraph_bridge/ngraph_mark_for_clustering.cc index 28c03ef1e..6d2693daa 100644 --- a/ngraph_bridge/ngraph_mark_for_clustering.cc +++ b/ngraph_bridge/ngraph_mark_for_clustering.cc @@ -59,7 +59,7 @@ using SetAttributesFunction = std::function; // // FIXME(amprocte): stubbed out for now because NGRAPH device is gone. // -static Status NGraphPlacementRequested(Node* node, bool& placement_ok) { +static Status NGraphPlacementRequested(Node*, bool& placement_ok) { placement_ok = true; return Status::OK(); } @@ -129,7 +129,7 @@ static SetAttributesFunction SetStaticInputs( // Generates a "simple" confirmation function which always returns true, static ConfirmationFunction SimpleConfirmationFunction() { - auto cf = [](Node* n, bool* result) { + auto cf = [](Node*, bool* result) { *result = true; return Status::OK(); }; @@ -655,7 +655,7 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, // Right now it cannot be inside the if(!initialized) block, because it is // backend dependent, which might change with different sess.run()s - confirmation_function_map["GatherV2"] = [¤t_backend](Node* n, + confirmation_function_map["GatherV2"] = [¤t_backend](Node*, bool* result) { // TODO: replace current_backend -> // BackendManager::GetCurrentlySetBackendName() @@ -666,7 +666,7 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, }; confirmation_function_map["NonMaxSuppressionV4"] = [¤t_backend]( - Node* n, bool* result) { + Node*, bool* result) { auto config_map = BackendManager::GetBackendAttributeValues(current_backend); *result = (config_map.at("ngraph_backend") == "NNPI"); @@ -674,7 +674,7 @@ Status MarkForClustering(Graph* graph, const std::set skip_these_nodes, }; confirmation_function_map["CombinedNonMaxSuppression"] = [¤t_backend]( - Node* n, bool* result) { + Node*, bool* result) { auto config_map = BackendManager::GetBackendAttributeValues(current_backend); *result = (config_map.at("ngraph_backend") == "NNPI"); diff --git a/ngraph_bridge/ngraph_tracked_variable.cc b/ngraph_bridge/ngraph_tracked_variable.cc index c45145165..bf277b6c1 100644 --- a/ngraph_bridge/ngraph_tracked_variable.cc +++ b/ngraph_bridge/ngraph_tracked_variable.cc @@ -133,7 +133,7 @@ void NGraphVariableOp::Compute(OpKernelContext* ctx) { // conditional on whether any reader is taking in a reference. More // conservative condition that would work for now: invalidate if any // reader is not NGraphEncapsulateOp. - auto t_creator = [this](NGraphFreshnessTracker** tracker) { + auto t_creator = [](NGraphFreshnessTracker** tracker) { *tracker = new NGraphFreshnessTracker(); return Status::OK(); }; diff --git a/ngraph_bridge/ngraph_utils.cc b/ngraph_bridge/ngraph_utils.cc index 8dbea634b..483bbae8a 100644 --- a/ngraph_bridge/ngraph_utils.cc +++ b/ngraph_bridge/ngraph_utils.cc @@ -55,7 +55,8 @@ Status IsNgraphTFLogTensorCopiesEnabled(int graph_id, test_graph_id = stoi(string(copy_env_var)); } catch (const std::invalid_argument& ia) { return errors::InvalidArgument( - "Invalid argument for NGRAPH_TF_LOG_TENSOR_COPIES"); + "Invalid argument for NGRAPH_TF_LOG_TENSOR_COPIES. Exception: ", + ia.what()); } // if -1 copies are logged for all graphs is_copy_log_enabled = (test_graph_id == -1 || test_graph_id == graph_id); diff --git a/ngraph_bridge/tf_deadness_analysis.cc b/ngraph_bridge/tf_deadness_analysis.cc index 53189f0e1..6c81d7e1a 100644 --- a/ngraph_bridge/tf_deadness_analysis.cc +++ b/ngraph_bridge/tf_deadness_analysis.cc @@ -118,7 +118,7 @@ class AndPredicate : public Predicate { std::transform(operands().begin(), operands().end(), std::back_inserter(operands_str), [](Predicate* pred) { return pred->ToString(); }); - return strings::StrCat("(", str_util::Join(operands_str, " & "), ")"); + return strings::StrCat("(", absl::StrJoin(operands_str, " & "), ")"); } bool operator==(const Predicate& other) const override { return other.kind() == Kind::kAnd && @@ -147,7 +147,7 @@ class OrPredicate : public Predicate { std::transform(operands().begin(), operands().end(), std::back_inserter(operands_str), [](Predicate* pred) { return pred->ToString(); }); - return strings::StrCat("(", str_util::Join(operands_str, " | "), ")"); + return strings::StrCat("(", absl::StrJoin(operands_str, " | "), ")"); } bool operator==(const Predicate& other) const override { return other.kind() == Kind::kOr && @@ -312,7 +312,7 @@ class DeadnessAnalysisImpl : public DeadnessAnalysis { Status Populate(); bool HasInputsWithMismatchingDeadness(const Node& node) override; void Print() const override; - Status GetNodePredicate(const Node& node, string& pred_string); + Status GetNodePredicate(const Node& node, string& pred_string) override; private: enum class EdgeKind { kDataAndControl, kDataOnly, kControlOnly }; diff --git a/test/encapsulate_op/encapsulate_op_test.cc b/test/encapsulate_op/encapsulate_op_test.cc index 7cb550d8b..b92f10650 100644 --- a/test/encapsulate_op/encapsulate_op_test.cc +++ b/test/encapsulate_op/encapsulate_op_test.cc @@ -103,7 +103,7 @@ TEST(EncapsulateOp, GetNgExecutable) { } ng_encap_impl.SetOpBackend("CPU"); - BackendManager::CreateBackend(ng_encap_impl.GetOpBackend()); + ASSERT_OK(BackendManager::CreateBackend(ng_encap_impl.GetOpBackend())); ng::runtime::Backend* op_backend; op_backend = BackendManager::GetBackend(ng_encap_impl.GetOpBackend()); @@ -125,7 +125,7 @@ TEST(EncapsulateOp, AllocateNGInputTensors) { ng::ParameterVector{A, B}); ng_encap_impl.SetOpBackend("CPU"); - BackendManager::CreateBackend(ng_encap_impl.GetOpBackend()); + ASSERT_OK(BackendManager::CreateBackend(ng_encap_impl.GetOpBackend())); ng::runtime::Backend* op_backend; op_backend = BackendManager::GetBackend(ng_encap_impl.GetOpBackend()); auto ng_exec = op_backend->compile(f); @@ -161,7 +161,7 @@ TEST(EncapsulateOp, AllocateNGOutputTensors) { ng::ParameterVector{A, B}); ng_encap_impl.SetOpBackend("CPU"); - BackendManager::CreateBackend(ng_encap_impl.GetOpBackend()); + ASSERT_OK(BackendManager::CreateBackend(ng_encap_impl.GetOpBackend())); ng::runtime::Backend* op_backend; op_backend = BackendManager::GetBackend(ng_encap_impl.GetOpBackend()); auto ng_exec = op_backend->compile(f); diff --git a/test/graph_rewrites/encapsulate_clusters_test.cc b/test/graph_rewrites/encapsulate_clusters_test.cc index 898feec6b..b46d812fe 100644 --- a/test/graph_rewrites/encapsulate_clusters_test.cc +++ b/test/graph_rewrites/encapsulate_clusters_test.cc @@ -17,10 +17,10 @@ #include "gtest/gtest.h" #include "tensorflow/core/graph/node_builder.h" -#include "version.h" #include "ngraph_bridge/ngraph_cluster_manager.h" #include "ngraph_bridge/ngraph_encapsulate_clusters.h" +#include "ngraph_bridge/version.h" #include "test/test_utilities.h" using namespace std; diff --git a/test/graph_rewrites/enter_in_catalog_test.cc b/test/graph_rewrites/enter_in_catalog_test.cc index 51321aac6..f2893611b 100644 --- a/test/graph_rewrites/enter_in_catalog_test.cc +++ b/test/graph_rewrites/enter_in_catalog_test.cc @@ -22,20 +22,20 @@ #include "tensorflow/core/graph/graph.h" #include "tensorflow/core/public/session.h" -#include "enable_variable_ops/ngraph_catalog.h" -#include "enable_variable_ops/ngraph_enter_in_catalog.h" -#include "enable_variable_ops/ngraph_replace_op_utilities.h" -#include "enable_variable_ops/ngraph_replace_variable_modifiers.h" -#include "ngraph_api.h" -#include "ngraph_assign_clusters.h" -#include "ngraph_capture_variables.h" -#include "ngraph_cluster_manager.h" -#include "ngraph_deassign_clusters.h" -#include "ngraph_encapsulate_clusters.h" -#include "ngraph_mark_for_clustering.h" -#include "ngraph_rewrite_for_tracking.h" -#include "ngraph_utils.h" -#include "tf_graph_writer.h" +#include "logging/tf_graph_writer.h" +#include "ngraph_bridge/enable_variable_ops/ngraph_catalog.h" +#include "ngraph_bridge/enable_variable_ops/ngraph_enter_in_catalog.h" +#include "ngraph_bridge/enable_variable_ops/ngraph_replace_op_utilities.h" +#include "ngraph_bridge/enable_variable_ops/ngraph_replace_variable_modifiers.h" +#include "ngraph_bridge/ngraph_api.h" +#include "ngraph_bridge/ngraph_assign_clusters.h" +#include "ngraph_bridge/ngraph_capture_variables.h" +#include "ngraph_bridge/ngraph_cluster_manager.h" +#include "ngraph_bridge/ngraph_deassign_clusters.h" +#include "ngraph_bridge/ngraph_encapsulate_clusters.h" +#include "ngraph_bridge/ngraph_mark_for_clustering.h" +#include "ngraph_bridge/ngraph_rewrite_for_tracking.h" +#include "ngraph_bridge/ngraph_utils.h" using namespace std; namespace ng = ngraph; diff --git a/test/opexecuter.cpp b/test/opexecuter.cpp index d0142e880..72ffa392a 100644 --- a/test/opexecuter.cpp +++ b/test/opexecuter.cpp @@ -217,7 +217,10 @@ void OpExecuter::ExecuteOnNGraph(vector& ngraph_outputs, } NGRAPH_VLOG(5) << " Creating NG Backend " << ng_backend_type; - BackendManager::CreateBackend(ng_backend_type); + Status status = BackendManager::CreateBackend(ng_backend_type); + if (!status.ok()) { + NGRAPH_VLOG(5) << "Cannot create backend " << ng_backend_type; + } auto backend = BackendManager::GetBackend(ng_backend_type); // Add the _ngraph_backend attr to the node diff --git a/test/test_variable_ops.cpp b/test/test_variable_ops.cpp index 3ce35e282..258d4f2df 100644 --- a/test/test_variable_ops.cpp +++ b/test/test_variable_ops.cpp @@ -166,7 +166,7 @@ TEST(VariableTest, SmallGraph2) { ASSERT_OK(tf_session.Run({assign_sub}, &tf_outputs2)); } - tf_session.Run({var}, &tf_outputs3); + ASSERT_OK(tf_session.Run({var}, &tf_outputs3)); Compare(tf_outputs1, ng_outputs1); Compare(tf_outputs2, ng_outputs2); diff --git a/tools/test_utils.py b/tools/test_utils.py index d7bafc493..a640c9e5c 100755 --- a/tools/test_utils.py +++ b/tools/test_utils.py @@ -599,9 +599,7 @@ def run_bazel_build_test(venv_dir, build_dir): command_executor(['bazel-bin/hello_tf']) # Now built the bigger app - command_executor([ - 'bazel', 'build', '//examples/cpp/infer_multiple_networks:infer_multi' - ]) + command_executor(['bazel', 'build', 'infer_multi']) # Return to the original directory os.chdir(root_pwd) @@ -620,5 +618,8 @@ def run_bazel_build(): # Run the cpp app - hello_tf command_executor(['bazel-bin/hello_tf']) + # Now built the bigger app + command_executor(['bazel', 'build', 'infer_multi']) + # Return to the original directory os.chdir(root_pwd)