aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api_function.cc
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2018-01-02 13:53:37 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-02 13:57:52 -0800
commit844e0c1984c626c440246b707f958953e0f6ef49 (patch)
tree142f4f882cdb04299f729bc91182bdb9b7009ca4 /tensorflow/c/c_api_function.cc
parent4c81792ebebc9c1dbd3bcd13073f85f3c8688ca5 (diff)
Speed up `OpKernel::InputRange()` by ~2.6x.
This reduces the typical amount of time spent converting an argument name into a range of positional arguments from ~59.5ns to ~22.5ns. To achieve this, the `NameRangeMap` is converted to borrow the argument names (as `tensorflow::StringPiece` objects) from the appropriate `OpDef`, instead of storing a string. This avoids allocating a string for each lookup. The map data structure is also changed from a `std::unordered_map` to a `gtl::FlatMap`. PiperOrigin-RevId: 180588460
Diffstat (limited to 'tensorflow/c/c_api_function.cc')
-rw-r--r--tensorflow/c/c_api_function.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/tensorflow/c/c_api_function.cc b/tensorflow/c/c_api_function.cc
index d60d1de315..dd6119e8aa 100644
--- a/tensorflow/c/c_api_function.cc
+++ b/tensorflow/c/c_api_function.cc
@@ -312,7 +312,7 @@ Status GraphToFunctionDef(const Graph& fn_body, const string& fn_name,
TF_RETURN_IF_ERROR(
NameRangesForNode(*node, node->op_def(), nullptr, &output_ranges));
for (const auto& output : output_ranges) {
- const string& output_name = output.first;
+ const StringPiece& output_name = output.first;
int index_start = output.second.first;
int index_end = output.second.second;
for (int i = index_start; i < index_end; ++i) {