Work around non-standard std::uniform_int_distribution<uint8_t>
std::uniform_int_distribution<uint8_t> is apparently non-standard and
unsupported by MSVC
PiperOrigin-RevId: 306408109
diff --git a/test/add-operator-tester.h b/test/add-operator-tester.h
index affb77d..eb13397 100644
--- a/test/add-operator-tester.h
+++ b/test/add-operator-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -178,7 +179,7 @@
void TestQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> a(XNN_EXTRA_BYTES / sizeof(uint8_t) + (batch_size() - 1) * a_stride() + channels());
std::vector<uint8_t> b(XNN_EXTRA_BYTES / sizeof(uint8_t) + (batch_size() - 1) * b_stride() + channels());
diff --git a/test/average-pooling-operator-tester.h b/test/average-pooling-operator-tester.h
index eb35e51..dd3765d 100644
--- a/test/average-pooling-operator-tester.h
+++ b/test/average-pooling-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -447,7 +448,7 @@
void TestQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + channels() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> output((batch_size() * output_height() * output_width() - 1) * output_pixel_stride() + channels());
@@ -627,7 +628,7 @@
void TestSetupQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + std::max(
(batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + channels(),
diff --git a/test/avgpool-microkernel-tester.h b/test/avgpool-microkernel-tester.h
index 339ecd2..c4fa9a2 100644
--- a/test/avgpool-microkernel-tester.h
+++ b/test/avgpool-microkernel-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -212,7 +213,7 @@
void Test(xnn_q8_avgpool_minmax_unipass_ukernel_function avgpool_minmax, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<const uint8_t*> indirect_input((output_pixels() - 1) * step() + packed_pooling_elements());
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
@@ -314,7 +315,7 @@
void Test(xnn_q8_avgpool_minmax_multipass_ukernel_function avgpool_minmax, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<const uint8_t*> indirect_input((output_pixels() - 1) * step() + packed_pooling_elements());
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
diff --git a/test/channel-shuffle-operator-tester.h b/test/channel-shuffle-operator-tester.h
index ad31c3f..531b635 100644
--- a/test/channel-shuffle-operator-tester.h
+++ b/test/channel-shuffle-operator-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -99,7 +100,7 @@
void TestX8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + (batch_size() - 1) * input_stride() + channels());
std::vector<uint8_t> output((batch_size() - 1) * output_stride() + channels());
diff --git a/test/clamp-microkernel-tester.h b/test/clamp-microkernel-tester.h
index 70846a1..6a1723e 100644
--- a/test/clamp-microkernel-tester.h
+++ b/test/clamp-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -79,7 +80,7 @@
void Test(xnn_u8_clamp_ukernel_function clamp, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> x(batch_size() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> y(batch_size() + (inplace() ? XNN_EXTRA_BYTES / sizeof(uint8_t) : 0));
diff --git a/test/clamp-operator-tester.h b/test/clamp-operator-tester.h
index 6e36bc0..04af4aa 100644
--- a/test/clamp-operator-tester.h
+++ b/test/clamp-operator-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -103,7 +104,7 @@
void TestU8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
(batch_size() - 1) * input_stride() + channels());
diff --git a/test/convolution-operator-tester.h b/test/convolution-operator-tester.h
index 70de774..8583c94 100644
--- a/test/convolution-operator-tester.h
+++ b/test/convolution-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -537,7 +538,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
batch_size() * ((input_height() * input_width() - 1) * input_pixel_stride() + groups() * group_input_channels()) + 8);
@@ -1028,7 +1029,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + std::max(
batch_size() * ((input_height() * input_width() - 1) * input_pixel_stride() + groups() * group_input_channels()),
diff --git a/test/deconvolution-operator-tester.h b/test/deconvolution-operator-tester.h
index 08f48e8..2fdfbcb 100644
--- a/test/deconvolution-operator-tester.h
+++ b/test/deconvolution-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -431,7 +432,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
(batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + groups() * group_input_channels());
@@ -700,7 +701,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + std::max(
(batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + groups() * group_input_channels(),
diff --git a/test/dwconv-microkernel-tester.h b/test/dwconv-microkernel-tester.h
index e1a58ca..20adb97 100644
--- a/test/dwconv-microkernel-tester.h
+++ b/test/dwconv-microkernel-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -153,7 +154,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<const uint8_t*> indirection((width() - 1) * step() + kr());
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + indirection.size() * channels());
diff --git a/test/fully-connected-operator-tester.h b/test/fully-connected-operator-tester.h
index cfc3738..b1d4f76 100644
--- a/test/fully-connected-operator-tester.h
+++ b/test/fully-connected-operator-tester.h
@@ -15,6 +15,7 @@
#include <algorithm>
#include <cmath>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -132,7 +133,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
(batch_size() - 1) * input_stride() + input_channels());
diff --git a/test/gavgpool-microkernel-tester.h b/test/gavgpool-microkernel-tester.h
index b246a43..e70fb00 100644
--- a/test/gavgpool-microkernel-tester.h
+++ b/test/gavgpool-microkernel-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -148,7 +149,7 @@
void Test(xnn_q8_gavgpool_minmax_unipass_ukernel_function gavgpool_minmax, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
(rows() - 1) * input_stride() + channels());
@@ -222,7 +223,7 @@
void Test(xnn_q8_gavgpool_minmax_multipass_ukernel_function gavgpool_minmax, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
(rows() - 1) * input_stride() + channels());
diff --git a/test/gemm-microkernel-tester.h b/test/gemm-microkernel-tester.h
index 7b1749d..a16e57e 100644
--- a/test/gemm-microkernel-tester.h
+++ b/test/gemm-microkernel-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -217,7 +218,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> a((m() - 1) * a_stride() + k() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> b(n() * k());
@@ -314,7 +315,7 @@
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto s32rng = std::bind(std::uniform_int_distribution<int32_t>(-10000, 10000), rng);
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> a((mr() - 1) * a_stride() + k() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> b(n() * ks() * k());
diff --git a/test/global-average-pooling-operator-tester.h b/test/global-average-pooling-operator-tester.h
index e6c3d23..4a3c9e4 100644
--- a/test/global-average-pooling-operator-tester.h
+++ b/test/global-average-pooling-operator-tester.h
@@ -15,6 +15,7 @@
#include <algorithm>
#include <cmath>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -153,7 +154,7 @@
void TestNWCxQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() * width() - 1) * input_stride() + channels() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> output(batch_size() * output_stride());
diff --git a/test/leaky-relu-operator-tester.h b/test/leaky-relu-operator-tester.h
index 5f4dce7..65e695d 100644
--- a/test/leaky-relu-operator-tester.h
+++ b/test/leaky-relu-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -155,7 +156,7 @@
void TestQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() - 1) * input_stride() + channels());
std::vector<uint8_t> output((batch_size() - 1) * output_stride() + channels());
diff --git a/test/lut-microkernel-tester.h b/test/lut-microkernel-tester.h
index ebd0b77..610acb5 100644
--- a/test/lut-microkernel-tester.h
+++ b/test/lut-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -54,7 +55,7 @@
void Test(xnn_x8_lut_ukernel_function lut) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> x(n());
std::vector<uint8_t> t(256);
diff --git a/test/lut-norm-microkernel-tester.h b/test/lut-norm-microkernel-tester.h
index 92e6aca..aa8655c 100644
--- a/test/lut-norm-microkernel-tester.h
+++ b/test/lut-norm-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -54,7 +55,7 @@
void Test(xnn_u8_lut32norm_ukernel_function lutnorm) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
auto u32rng = std::bind(
std::uniform_int_distribution<uint32_t>(1, std::numeric_limits<uint32_t>::max() / (257 * n())),
rng);
diff --git a/test/max-pooling-operator-tester.h b/test/max-pooling-operator-tester.h
index c018da4..7da7ffd 100644
--- a/test/max-pooling-operator-tester.h
+++ b/test/max-pooling-operator-tester.h
@@ -450,7 +450,7 @@
void TestU8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + channels() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> output((batch_size() * output_height() * output_width() - 1) * output_pixel_stride() + channels() + XNN_EXTRA_BYTES / sizeof(uint8_t));
@@ -631,7 +631,7 @@
void TestSetupU8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) + std::max(
(batch_size() * input_height() * input_width() - 1) * input_pixel_stride() + channels(),
diff --git a/test/maxpool-microkernel-tester.h b/test/maxpool-microkernel-tester.h
index 1124095..9766108 100644
--- a/test/maxpool-microkernel-tester.h
+++ b/test/maxpool-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -160,7 +161,7 @@
void Test(xnn_u8_maxpool_ukernel_function maxpool, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<const uint8_t*> indirect_input((output_pixels() - 1) * step() + packed_pooling_elements());
std::vector<uint8_t> input(XNN_EXTRA_BYTES / sizeof(uint8_t) +
diff --git a/test/requantization-tester.h b/test/requantization-tester.h
index bd1b4db..3410ada 100644
--- a/test/requantization-tester.h
+++ b/test/requantization-tester.h
@@ -10,13 +10,13 @@
#include <gtest/gtest.h>
-#include <cstddef>
-#include <cstdlib>
-
#include <algorithm>
#include <cfloat>
#include <cmath>
+#include <cstddef>
+#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -249,18 +249,18 @@
void TestRandomCasesPrecise(requantization_function requantize) {
std::random_device random_device;
- std::mt19937 mtRng(random_device());
+ std::mt19937 rng(random_device());
for (size_t iteration = 0; iteration < iterations(); iteration++) {
- auto rng = std::bind(std::uniform_int_distribution<uint8_t>(), mtRng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<int32_t> inputs(4096);
std::vector<uint8_t> outputs(inputs.size());
const uint8_t zero_point = UINT8_C(128);
std::uniform_real_distribution<float> scale_distribution(0x1.000000p-23f, 0x1.FFFFFEp-1f);
- const float scale = scale_distribution(mtRng);
+ const float scale = scale_distribution(rng);
for (size_t i = 0; i < inputs.size(); i++) {
- const uint8_t approximate_output = rng();
+ const uint8_t approximate_output = u8rng();
const int32_t input = int32_t(double(approximate_output) / double(scale));
inputs[i] = input;
}
@@ -289,18 +289,18 @@
void TestRandomCasesApproximate(requantization_function requantize) {
std::random_device random_device;
- std::mt19937 mtRng(random_device());
+ std::mt19937 rng(random_device());
for (size_t iteration = 0; iteration < iterations(); iteration++) {
- auto rng = std::bind(std::uniform_int_distribution<uint8_t>(), mtRng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<int32_t> inputs(4096);
std::vector<uint8_t> outputs(inputs.size());
const uint8_t zero_point = UINT8_C(128);
std::uniform_real_distribution<float> scale_distribution(0x1.000000p-23f, 0x1.FFFFFEp-1f);
- const float scale = scale_distribution(mtRng);
+ const float scale = scale_distribution(rng);
for (size_t i = 0; i < inputs.size(); i++) {
- const uint8_t approximate_output = rng();
+ const uint8_t approximate_output = u8rng();
const int32_t input = int32_t(double(approximate_output) / double(scale));
inputs[i] = input;
}
@@ -331,9 +331,9 @@
void TestRandomCasesAgainstReference(requantization_function requantize, requantization_function requantize_reference) {
std::random_device random_device;
- std::mt19937 mtRng(random_device());
+ std::mt19937 rng(random_device());
for (size_t iteration = 0; iteration < iterations(); iteration++) {
- auto rng = std::bind(std::uniform_int_distribution<uint8_t>(), mtRng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<int32_t> inputs(4096);
std::vector<uint8_t> outputs(inputs.size());
@@ -341,9 +341,9 @@
const uint8_t zero_point = UINT8_C(128);
std::uniform_real_distribution<float> scale_distribution(0x1.000000p-23f, 0x1.FFFFFEp-1f);
- const float scale = scale_distribution(mtRng);
+ const float scale = scale_distribution(rng);
for (size_t i = 0; i < inputs.size(); i++) {
- const uint8_t approximate_output = rng();
+ const uint8_t approximate_output = u8rng();
const int32_t input = int32_t(double(approximate_output) / double(scale));
inputs[i] = input;
}
diff --git a/test/rmax-microkernel-tester.h b/test/rmax-microkernel-tester.h
index 729f2eb..9025328 100644
--- a/test/rmax-microkernel-tester.h
+++ b/test/rmax-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -45,7 +46,7 @@
void Test(xnn_u8_rmax_ukernel_function rmax) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> x(n());
for (size_t iteration = 0; iteration < iterations(); iteration++) {
diff --git a/test/sigmoid-operator-tester.h b/test/sigmoid-operator-tester.h
index aa4a465..bf65b51 100644
--- a/test/sigmoid-operator-tester.h
+++ b/test/sigmoid-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -132,7 +133,7 @@
void TestQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() - 1) * input_stride() + channels() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> output((batch_size() - 1) * output_stride() + channels());
diff --git a/test/softmax-operator-tester.h b/test/softmax-operator-tester.h
index eb79962..05d6e28 100644
--- a/test/softmax-operator-tester.h
+++ b/test/softmax-operator-tester.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -114,7 +115,7 @@
void TestQ8() const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> input((batch_size() - 1) * input_stride() + channels());
std::vector<uint8_t> output((batch_size() - 1) * output_stride() + channels());
diff --git a/test/vadd-microkernel-tester.h b/test/vadd-microkernel-tester.h
index aab3dd4..0e1b273 100644
--- a/test/vadd-microkernel-tester.h
+++ b/test/vadd-microkernel-tester.h
@@ -15,6 +15,7 @@
#include <cstddef>
#include <cstdlib>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -149,7 +150,7 @@
void Test(xnn_q8_vadd_minmax_ukernel_function vadd_minmax, Variant variant = Variant::Native) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> a(n() + XNN_EXTRA_BYTES / sizeof(uint8_t));
std::vector<uint8_t> b(n() + XNN_EXTRA_BYTES / sizeof(uint8_t));
diff --git a/test/zip-microkernel-tester.h b/test/zip-microkernel-tester.h
index 7a292da..361be78 100644
--- a/test/zip-microkernel-tester.h
+++ b/test/zip-microkernel-tester.h
@@ -17,6 +17,7 @@
#include <cfloat>
#include <cmath>
#include <functional>
+#include <limits>
#include <random>
#include <vector>
@@ -57,7 +58,7 @@
void Test(xnn_x8_zipc_ukernel_function zip) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> x(n() * g());
std::vector<uint8_t> y(g() * n());
@@ -82,7 +83,7 @@
void Test(xnn_x8_zipv_ukernel_function zip) const {
std::random_device random_device;
auto rng = std::mt19937(random_device());
- auto u8rng = std::bind(std::uniform_int_distribution<uint8_t>(), rng);
+ auto u8rng = std::bind(std::uniform_int_distribution<uint32_t>(0, std::numeric_limits<uint8_t>::max()), rng);
std::vector<uint8_t> x(n() * g());
std::vector<uint8_t> y(g() * n());