diff options
author | Derek Murray <mrry@google.com> | 2018-01-02 13:53:37 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-01-02 13:57:52 -0800 |
commit | 844e0c1984c626c440246b707f958953e0f6ef49 (patch) | |
tree | 142f4f882cdb04299f729bc91182bdb9b7009ca4 /tensorflow/core/framework/op_kernel.cc | |
parent | 4c81792ebebc9c1dbd3bcd13073f85f3c8688ca5 (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/core/framework/op_kernel.cc')
-rw-r--r-- | tensorflow/core/framework/op_kernel.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/core/framework/op_kernel.cc b/tensorflow/core/framework/op_kernel.cc index 4d410809e7..433005c8ab 100644 --- a/tensorflow/core/framework/op_kernel.cc +++ b/tensorflow/core/framework/op_kernel.cc @@ -112,7 +112,7 @@ const string& OpKernel::requested_input(int i) const { return def_->input(i); } Status OpKernel::InputRange(StringPiece input_name, int* start, int* stop) const { - const auto result = input_name_map_.find(input_name.ToString()); + const auto result = input_name_map_.find(input_name); if (result == input_name_map_.end()) { return errors::InvalidArgument("Unknown input name: ", input_name); } else { @@ -124,7 +124,7 @@ Status OpKernel::InputRange(StringPiece input_name, int* start, Status OpKernel::OutputRange(StringPiece output_name, int* start, int* stop) const { - const auto result = output_name_map_.find(output_name.ToString()); + const auto result = output_name_map_.find(output_name); if (result == output_name_map_.end()) { return errors::InvalidArgument("Unknown output name: ", output_name); } else { |