From: A. Unique TensorFlower Date: Thu, 17 May 2018 18:13:00 +0000 (-0700) Subject: Use integral power function rather than floating point version. The integral version... X-Git-Tag: upstream/v1.9.0_rc1~94^2^2~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e2ce8f4c483e68309a60dc89739bb1b79b4a12e;p=platform%2Fupstream%2Ftensorflow.git Use integral power function rather than floating point version. The integral version is faster. PiperOrigin-RevId: 197021020 --- diff --git a/tensorflow/core/grappler/optimizers/memory_optimizer.cc b/tensorflow/core/grappler/optimizers/memory_optimizer.cc index 7c6468b..1be5f8d 100644 --- a/tensorflow/core/grappler/optimizers/memory_optimizer.cc +++ b/tensorflow/core/grappler/optimizers/memory_optimizer.cc @@ -36,6 +36,7 @@ limitations under the License. #include "tensorflow/core/grappler/utils.h" #include "tensorflow/core/grappler/utils/topological_sort.h" #include "tensorflow/core/grappler/utils/traversal.h" +#include "tensorflow/core/lib/math/math_util.h" #include "tensorflow/core/protobuf/rewriter_config.pb.h" namespace tensorflow { @@ -1069,9 +1070,11 @@ static bool IdentifySwappingCandidates( // ensure that swapping the tensor back in won't recreate the memory // bottleneck. Last but not least, we want the tensor to have as few // remaining uses as possible. - mem_info.fitness = std::pow((earliest_use - peak_time).count(), 2); - mem_info.fitness /= std::pow(mem_info.uses_left.size(), 2); - mem_info.fitness += std::pow((allocation_time - peak_time).count(), 2); + mem_info.fitness = + MathUtil::IPow((earliest_use - peak_time).count(), 2); + mem_info.fitness /= MathUtil::IPow(mem_info.uses_left.size(), 2); + mem_info.fitness += + MathUtil::IPow((allocation_time - peak_time).count(), 2); mem_info.fitness = -mem_info.fitness; mem_state.push_back(mem_info); }