diff options
author | 2016-05-18 08:04:37 -0800 | |
---|---|---|
committer | 2016-05-18 09:11:05 -0700 | |
commit | 60adf6fe001ebef450120ce0b81412b666c02649 (patch) | |
tree | 4b61e41627ace3aaa567985fa383e9e34dd496fa /tensorflow/core/example/example_parser_configuration.h | |
parent | 91615e7667b6e3c21c8c61f5accaf4cba89b3b06 (diff) |
Add ExtractExampleParserConfiguration method
- Extract the fixed length and variable length feature configurations
output tensor names from a given GraphDef.
- This will allow for the use case of bypassing an unnecessary tensorflow.Example
serialize/deserialize at serving/inference time by extracting the configuration,
running the proto -> tensor helpers directly and feeding the graph with
the properly named tensors
Change: 122636456
Diffstat (limited to 'tensorflow/core/example/example_parser_configuration.h')
-rw-r--r-- | tensorflow/core/example/example_parser_configuration.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tensorflow/core/example/example_parser_configuration.h b/tensorflow/core/example/example_parser_configuration.h new file mode 100644 index 0000000000..cf90dd7f4b --- /dev/null +++ b/tensorflow/core/example/example_parser_configuration.h @@ -0,0 +1,47 @@ +/* Copyright 2016 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef THIRD_PARTY_TENSORFLOW_CORE_EXAMPLE_EXAMPLE_PARSER_CONFIGURATION_H_ +#define THIRD_PARTY_TENSORFLOW_CORE_EXAMPLE_EXAMPLE_PARSER_CONFIGURATION_H_ + +#include <string> +#include <vector> + +#include "tensorflow/core/example/example.pb.h" +#include "tensorflow/core/framework/allocator.h" +#include "tensorflow/core/framework/graph.pb.h" +#include "tensorflow/core/framework/tensor.h" +#include "tensorflow/core/framework/types.h" +#include "tensorflow/core/platform/types.h" +#include "tensorflow/core/public/session.h" +#include "tensorflow/core/util/example_proto_helper.h" +#include "tensorflow/core/util/sparse/sparse_tensor.h" + +// This is a set of helper methods that will make it possible to share +// tensorflow::Example proto Tensor conversion code inside the ExampleParserOp +// OpKernel as well as in external code. +namespace tensorflow { + +// Given a graph and the node_name of a ParseExample op, +// extract the FixedLenFeature/VarLenFeature configurations. +Status ExtractExampleParserConfiguration( + const tensorflow::GraphDef& graph, const string& node_name, + tensorflow::Session* session, + std::vector<FixedLenFeature>* fixed_len_features, + std::vector<VarLenFeature>* var_len_features); + +} // namespace tensorflow + +#endif // THIRD_PARTY_TENSORFLOW_CORE_EXAMPLE_EXAMPLE_PARSE_CONFIGURATION_H_ |