diff options
author | Derek Murray <mrry@google.com> | 2018-09-12 09:29:45 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-12 09:33:33 -0700 |
commit | 1c4fceab7dc09cab18c0def098320d6c52d2e514 (patch) | |
tree | 7d38e14e61c952abaf1f286ddadd7d6302b517f5 /tensorflow/contrib/boosted_trees | |
parent | 6b507a6de855a6f988100904229b7f46a5652b88 (diff) |
Change HandleFromInput() to return a `const ResourceHandle&` and avoid copying that type.
This avoids unnecessary string copies and deallocations in the ReadVariableOp, and similar ops.
PiperOrigin-RevId: 212652588
Diffstat (limited to 'tensorflow/contrib/boosted_trees')
-rw-r--r-- | tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc | 10 | ||||
-rw-r--r-- | tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc b/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc index 1375fddf2b..606da663dc 100644 --- a/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc +++ b/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc @@ -296,8 +296,9 @@ class QuantileAccumulatorAddSummariesOp : public OpKernel { int64 start, int64 end) { for (int resource_handle_idx = start; resource_handle_idx < end; ++resource_handle_idx) { - ResourceHandle handle = resource_handle_list[resource_handle_idx] - .flat<ResourceHandle>()(0); + const ResourceHandle& handle = + resource_handle_list[resource_handle_idx] + .flat<ResourceHandle>()(0); QuantileStreamResource* streams_resource; // Create a reference to the underlying resource using the handle. OP_REQUIRES_OK(context, @@ -709,8 +710,9 @@ class QuantileAccumulatorGetBucketsOp : public OpKernel { &buckets_list, stamp_token](int64 start, int64 end) { for (int resource_handle_idx = start; resource_handle_idx < end; ++resource_handle_idx) { - ResourceHandle handle = resource_handle_list[resource_handle_idx] - .flat<ResourceHandle>()(0); + const ResourceHandle& handle = + resource_handle_list[resource_handle_idx] + .flat<ResourceHandle>()(0); QuantileStreamResource* streams_resource; OP_REQUIRES_OK(context, LookupResource(context, handle, &streams_resource)); diff --git a/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc b/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc index 90a0655201..e446c411a8 100644 --- a/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc +++ b/tensorflow/contrib/boosted_trees/kernels/stats_accumulator_ops.cc @@ -448,8 +448,9 @@ class StatsAccumulatorScalarAddOp : public OpKernel { stamp_token](int64 start, int64 end) { for (int resource_handle_idx = start; resource_handle_idx < end; ++resource_handle_idx) { - ResourceHandle handle = resource_handle_list[resource_handle_idx] - .flat<ResourceHandle>()(0); + const ResourceHandle& handle = + resource_handle_list[resource_handle_idx] + .flat<ResourceHandle>()(0); StatsAccumulatorScalarResource* accumulator_resource; OP_REQUIRES_OK(context, LookupResource(context, handle, @@ -512,8 +513,9 @@ class StatsAccumulatorTensorAddOp : public OpKernel { stamp_token](int64 start, int64 end) { for (int resource_handle_idx = start; resource_handle_idx < end; ++resource_handle_idx) { - ResourceHandle handle = resource_handle_list[resource_handle_idx] - .flat<ResourceHandle>()(0); + const ResourceHandle& handle = + resource_handle_list[resource_handle_idx] + .flat<ResourceHandle>()(0); StatsAccumulatorTensorResource* accumulator_resource; OP_REQUIRES_OK(context, LookupResource(context, handle, |