diff --git a/tensorflow/core/kernels/dequantize_op_test.cc b/tensorflow/core/kernels/dequantize_op_test.cc index 06269e6e965..3c9d1790787 100644 --- a/tensorflow/core/kernels/dequantize_op_test.cc +++ b/tensorflow/core/kernels/dequantize_op_test.cc @@ -15,6 +15,7 @@ limitations under the License. #include #include +#include #include #include "tensorflow/cc/ops/array_ops.h" @@ -128,6 +129,7 @@ class DequantizeOpTest : public OpsTestBase { std::vector ScalePerSliceAlongAxis(std::vector dims, int axis, const std::vector& data) { uint32 seed = 123; + std::minstd_rand rng(seed); int64 out_size = 1; for (int dim : dims) { out_size *= dim; @@ -139,7 +141,7 @@ class DequantizeOpTest : public OpsTestBase { std::vector out(out_size); int num_slices = (axis == -1) ? 1 : dims[axis]; for (int out_idx = 0; out_idx < out_size; ++out_idx) { - int in_idx = rand_r(&seed) % data.size(); + int in_idx = rng() % data.size(); T multiplier = ((out_idx / minor_size) % num_slices) + 1; out[out_idx] = data[in_idx] * multiplier; } diff --git a/tensorflow/core/kernels/quantize_op_test.cc b/tensorflow/core/kernels/quantize_op_test.cc index 6244df8d754..e4488fc431b 100644 --- a/tensorflow/core/kernels/quantize_op_test.cc +++ b/tensorflow/core/kernels/quantize_op_test.cc @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include + #include "tensorflow/core/framework/fake_input.h" #include "tensorflow/core/framework/node_def_builder.h" #include "tensorflow/core/framework/tensor.h" @@ -61,6 +63,7 @@ template std::vector ScalePerSliceAlongAxis(std::vector dims, int axis, const std::vector& data) { uint32 seed = 123; + std::minstd_rand rng(seed); int64 out_size = 1; for (int dim : dims) { out_size *= dim; @@ -72,7 +75,7 @@ std::vector ScalePerSliceAlongAxis(std::vector dims, int axis, std::vector out(out_size); int num_slices = (axis == -1) ? 1 : dims[axis]; for (int out_idx = 0; out_idx < out_size; ++out_idx) { - int in_idx = rand_r(&seed) % data.size(); + int in_idx = rng() % data.size(); T multiplier = ((out_idx / minor_size) % num_slices) + 1; out[out_idx] = data[in_idx] * multiplier; }