From 7879c387f8a4a236cb031aa3d54252e9f14771be Mon Sep 17 00:00:00 2001
From: Gunhan Gulsoy <gunan@google.com>
Date: Fri, 29 Nov 2019 21:16:44 -0800
Subject: [PATCH] Move core/lib/random/random to core/platform

PiperOrigin-RevId: 283111631
Change-Id: I8ef4e09e5035721c45a64ecc7eb598ba448b82ed
---
 tensorflow/core/lib/random/BUILD              |  5 +--
 tensorflow/core/lib/random/random.h           | 16 +--------
 tensorflow/core/platform/BUILD                | 12 +++++++
 .../core/{lib/random => platform}/random.cc   |  2 +-
 tensorflow/core/platform/random.h             | 35 +++++++++++++++++++
 5 files changed, 50 insertions(+), 20 deletions(-)
 rename tensorflow/core/{lib/random => platform}/random.cc (96%)
 create mode 100644 tensorflow/core/platform/random.h

diff --git a/tensorflow/core/lib/random/BUILD b/tensorflow/core/lib/random/BUILD
index c9d48689849..7360e72f233 100644
--- a/tensorflow/core/lib/random/BUILD
+++ b/tensorflow/core/lib/random/BUILD
@@ -64,11 +64,9 @@ cc_library(
 
 cc_library(
     name = "random",
-    srcs = ["random.cc"],
     hdrs = ["random.h"],
     deps = [
-        "//tensorflow/core/platform:mutex",
-        "//tensorflow/core/platform:types",
+        "//tensorflow/core/platform:random",
     ],
 )
 
@@ -133,7 +131,6 @@ filegroup(
     name = "legacy_lib_random_all_srcs",
     srcs = [
         "distribution_sampler.cc",
-        "random.cc",
         "random_distributions.cc",
         "simple_philox.cc",
         "weighted_picker.cc",
diff --git a/tensorflow/core/lib/random/random.h b/tensorflow/core/lib/random/random.h
index 5335c8cc3c9..e280d98d551 100644
--- a/tensorflow/core/lib/random/random.h
+++ b/tensorflow/core/lib/random/random.h
@@ -16,20 +16,6 @@ limitations under the License.
 #ifndef TENSORFLOW_LIB_RANDOM_RANDOM_H_
 #define TENSORFLOW_LIB_RANDOM_RANDOM_H_
 
-#include "tensorflow/core/platform/types.h"
-
-namespace tensorflow {
-namespace random {
-
-// Return a 64-bit random value.  Different sequences are generated
-// in different processes.
-uint64 New64();
-
-// Return a 64-bit random value. Uses
-// std::mersenne_twister_engine::default_seed as seed value.
-uint64 New64DefaultSeed();
-
-}  // namespace random
-}  // namespace tensorflow
+#include "tensorflow/core/platform/random.h"
 
 #endif  // TENSORFLOW_LIB_RANDOM_RANDOM_H_
diff --git a/tensorflow/core/platform/BUILD b/tensorflow/core/platform/BUILD
index 87b6fa1af1b..f743e01ba8a 100644
--- a/tensorflow/core/platform/BUILD
+++ b/tensorflow/core/platform/BUILD
@@ -376,6 +376,16 @@ cc_library(
     ] + if_static(["@com_google_protobuf//:protobuf"]),
 )
 
+cc_library(
+    name = "random",
+    srcs = ["random.cc"],
+    hdrs = ["random.h"],
+    deps = [
+        ":mutex",
+        ":types",
+    ],
+)
+
 cc_library(
     name = "raw_coding",
     hdrs = ["raw_coding.h"],
@@ -713,6 +723,7 @@ filegroup(
             "numbers.cc",
             "platform_strings.cc",
             "protobuf.cc",
+            "random.cc",
             "scanner.cc",
             "strcat.cc",
             "stringprintf.cc",
@@ -824,6 +835,7 @@ filegroup(
             "platform_strings.cc",
             "protobuf.cc",
             "protobuf_util.cc",
+            "random.cc",
             "scanner.cc",
             "setround.cc",
             "status.cc",
diff --git a/tensorflow/core/lib/random/random.cc b/tensorflow/core/platform/random.cc
similarity index 96%
rename from tensorflow/core/lib/random/random.cc
rename to tensorflow/core/platform/random.cc
index 82dc8295073..d7252810021 100644
--- a/tensorflow/core/lib/random/random.cc
+++ b/tensorflow/core/platform/random.cc
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 ==============================================================================*/
 
-#include "tensorflow/core/lib/random/random.h"
+#include "tensorflow/core/platform/random.h"
 
 #include <random>
 #include "tensorflow/core/platform/mutex.h"
diff --git a/tensorflow/core/platform/random.h b/tensorflow/core/platform/random.h
new file mode 100644
index 00000000000..f605fd9e477
--- /dev/null
+++ b/tensorflow/core/platform/random.h
@@ -0,0 +1,35 @@
+/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+#ifndef TENSORFLOW_CORE_PLATFORM_RANDOM_H_
+#define TENSORFLOW_CORE_PLATFORM_RANDOM_H_
+
+#include "tensorflow/core/platform/types.h"
+
+namespace tensorflow {
+namespace random {
+
+// Return a 64-bit random value.  Different sequences are generated
+// in different processes.
+uint64 New64();
+
+// Return a 64-bit random value. Uses
+// std::mersenne_twister_engine::default_seed as seed value.
+uint64 New64DefaultSeed();
+
+}  // namespace random
+}  // namespace tensorflow
+
+#endif  // TENSORFLOW_CORE_PLATFORM_RANDOM_H_