Skip to content
Closed
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
3 changes: 3 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ tf_cc_binary(
visibility = ["//visibility:public"],
)

# In order to use this example with bazel you will
# need uncomment 2 lines mentioned in
# examples/cpp/inference/infer_multiple_networks.cc
tf_cc_binary(
name = 'infer_multiple_networks',
srcs = [
Expand Down
4 changes: 4 additions & 0 deletions examples/cpp/hello_tf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/public/session.h"

#include "ngraph/component_manager.hpp"

#include "ngraph_bridge/ngraph_api.h"
#include "ngraph_bridge/ngraph_backend_manager.h"
#include "ngraph_bridge/version.h"
Expand All @@ -36,6 +38,8 @@ using namespace std;

// Prints the available backends
void PrintAvailableBackends() {
// Register the backend
ngraph_register_cpu_backend();
// Get the list of backends
auto supported_backends =
tensorflow::ngraph_bridge::BackendManager::GetSupportedBackendNames();
Expand Down
12 changes: 9 additions & 3 deletions examples/cpp/inference/infer_multiple_networks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/util/command_line_flags.h"

// uncomment this when using bazel
// #include "ngraph/component_manager.hpp"
#include "ngraph/event_tracing.hpp"

#include "ngraph_bridge/ngraph_backend_manager.h"
Expand All @@ -52,6 +54,10 @@ extern tf::Status CheckTopLabel(const std::vector<tf::Tensor>& outputs,

// Prints the available backends
void PrintAvailableBackends() {
// Register the backend
// uncomment this when using bazel
// ngraph_register_cpu_backend();

// Get the list of backends
auto supported_backends =
tf::ngraph_bridge::BackendManager::GetSupportedBackendNames();
Expand Down Expand Up @@ -164,15 +170,15 @@ int main(int argc, char** argv) {
return -1;
}

std::cout << "Component versions\n";
PrintVersion();

const char* backend = "CPU";
if (SetNGraphBackend(backend) != tf::Status::OK()) {
std::cout << "Error: Cannot set the backend: " << backend << std::endl;
return -1;
}

std::cout << "Component versions\n";
PrintVersion();

// If batch size is more than one then expand the input
vector<string> image_files;
for (int i = 0; i < batch_size; i++) {
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/inference/tf_label_image_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Status ReadTensorFromImageFile(const std::vector<string>& file_names,
std::vector<std::pair<string, tensorflow::Tensor>> inputs;
std::vector<tensorflow::Output> div_tensors;

for (int i = 0; i < file_names.size(); i++) {
for (auto i = 0; i < file_names.size(); i++) {
// read file_name into a tensor named input
Tensor input(tensorflow::DT_STRING, tensorflow::TensorShape());
TF_RETURN_IF_ERROR(
Expand Down