diff options
author | Sanjoy Das <sanjoy@google.com> | 2017-11-30 14:26:58 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-11-30 14:30:23 -0800 |
commit | 6bfc73a0b3c6810725a5eb0020470457cc5cc23e (patch) | |
tree | bbd11451f4c7ac5ae4ffa8233e6a2ffaa541d0a8 /tensorflow/core/lib/core | |
parent | 6ebb6d6465ddf2380430de7aa287676e9440df7e (diff) |
Extract out a MathUtil::GCD helper
This fixes a TODO.
PiperOrigin-RevId: 177508258
Diffstat (limited to 'tensorflow/core/lib/core')
-rw-r--r-- | tensorflow/core/lib/core/arena.cc | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/tensorflow/core/lib/core/arena.cc b/tensorflow/core/lib/core/arena.cc index 2a04f7bd39..55e481d0e6 100644 --- a/tensorflow/core/lib/core/arena.cc +++ b/tensorflow/core/lib/core/arena.cc @@ -28,6 +28,7 @@ limitations under the License. #include <algorithm> #include <vector> +#include "tensorflow/core/lib/math/math_util.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/platform/mem.h" @@ -113,24 +114,11 @@ void Arena::MakeNewBlock(const uint32 alignment) { CHECK(SatisfyAlignment(alignment)); } -// The following simple numeric routines also exist in util/math/mathutil.h -// but we don't want to depend on that library. - -// Euclid's algorithm for Greatest Common Denominator. -static uint32 GCD(uint32 x, uint32 y) { - while (y != 0) { - uint32 r = x % y; - x = y; - y = r; - } - return x; -} - static uint32 LeastCommonMultiple(uint32 a, uint32 b) { if (a > b) { - return (a / GCD(a, b)) * b; + return (a / MathUtil::GCD<uint32>(a, b)) * b; } else if (a < b) { - return (b / GCD(b, a)) * a; + return (b / MathUtil::GCD<uint32>(b, a)) * a; } else { return a; } |