Remove uses of rand_r in quantize/dequantize op_test.
rand_r is not available on windows. PiperOrigin-RevId: 289270961 Change-Id: I94a287bbcf213fd1656d8e34636c23339db2b219
This commit is contained in:
parent
6aaa640cec
commit
eb068fbfca
tensorflow/core/kernels
@ -15,6 +15,7 @@ limitations under the License.
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
#include "tensorflow/cc/ops/array_ops.h"
|
||||
@ -128,6 +129,7 @@ class DequantizeOpTest : public OpsTestBase {
|
||||
std::vector<T> ScalePerSliceAlongAxis(std::vector<int64> dims, int axis,
|
||||
const std::vector<T>& 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<T> 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;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#include <random>
|
||||
|
||||
#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 <typename T>
|
||||
std::vector<T> ScalePerSliceAlongAxis(std::vector<int64> dims, int axis,
|
||||
const std::vector<T>& 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<T> ScalePerSliceAlongAxis(std::vector<int64> dims, int axis,
|
||||
std::vector<T> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user