Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
35 changes: 35 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"],
)
33 changes: 0 additions & 33 deletions examples/cpp/infer_multiple_networks/BUILD

This file was deleted.

4 changes: 2 additions & 2 deletions examples/cpp/infer_multiple_networks/inference_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ extern tf::Status ReadTensorFromImageFile(const std::vector<string>& 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<string>& image_files,
int input_width, int input_height,
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/infer_multiple_networks/inference_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>& image_files,
Expand Down
24 changes: 12 additions & 12 deletions examples/cpp/infer_multiple_networks/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions examples/cpp/tf_label_image_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ Status ReadTensorFromImageFile(const std::vector<string>& 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
5 changes: 4 additions & 1 deletion ngraph_bridge/enable_variable_ops/ngraph_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_);

Expand Down
9 changes: 6 additions & 3 deletions ngraph_bridge/ngraph_assign_clusters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Loading