diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-06-12 18:12:30 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-06-12 18:16:13 -0700 |
commit | 9f10f60fbd9fefaf225c1985014010b6b2f738c1 (patch) | |
tree | 1054fd871c9b7703d74e9c6d017543ee30e907b3 /tensorflow/core/example | |
parent | 995f5f4f40721e177f94cf954060619111e5cc4c (diff) |
Minor modernizations, mostly more <memory>
PiperOrigin-RevId: 158793461
Diffstat (limited to 'tensorflow/core/example')
-rw-r--r-- | tensorflow/core/example/example_parser_configuration_test.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tensorflow/core/example/example_parser_configuration_test.cc b/tensorflow/core/example/example_parser_configuration_test.cc index 647f727d83..a2238faaf3 100644 --- a/tensorflow/core/example/example_parser_configuration_test.cc +++ b/tensorflow/core/example/example_parser_configuration_test.cc @@ -14,6 +14,8 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/core/example/example_parser_configuration.h" +#include <memory> + #include "tensorflow/core/framework/attr_value.pb.h" #include "tensorflow/core/framework/node_def.pb.h" #include "tensorflow/core/framework/tensor_testutil.h" @@ -30,10 +32,11 @@ namespace { void ReadFileToStringOrDie(Env* env, const string& filename, string* output) { TF_CHECK_OK(ReadFileToString(env, filename, output)); } -Session* CreateSession() { + +std::unique_ptr<Session> CreateSession() { SessionOptions options; (*options.config.mutable_device_count())["CPU"] = 2; - return NewSession(options); + return std::unique_ptr<Session>(NewSession(options)); } class ExtractExampleParserConfigurationTest : public ::testing::Test { @@ -45,19 +48,19 @@ class ExtractExampleParserConfigurationTest : public ::testing::Test { "core/example/testdata/parse_example_graph_def.pbtxt"); ReadFileToStringOrDie(Env::Default(), filename, &proto_string); protobuf::TextFormat::ParseFromString(proto_string, &graph_def_); - session_.reset(CreateSession()); + session_ = CreateSession(); TF_CHECK_OK(session_->Create(graph_def_)); } NodeDef* parse_example_node() { - for (int i = 0; i < graph_def_.node_size(); ++i) { - auto mutable_node = graph_def_.mutable_node(i); - if (mutable_node->name() == "ParseExample/ParseExample") { - return mutable_node; + for (auto& node : *graph_def_.mutable_node()) { + if (node.name() == "ParseExample/ParseExample") { + return &node; } } return nullptr; } + GraphDef graph_def_; std::unique_ptr<Session> session_; }; |