[IE Tools] Fix seed for random generator in benchmark_app(s) to have reproducable data between runs of the same application (#4757)

This commit is contained in:
Nadezhda Ageeva
2021-03-13 16:41:39 +03:00
committed by GitHub
parent 11f591c168
commit f41634eaba
2 changed files with 4 additions and 4 deletions

View File

@@ -168,8 +168,7 @@ void fillBlobRandom(Blob::Ptr& inputBlob,
auto minputHolder = minput->wmap();
auto inputBlobData = minputHolder.as<T *>();
std::random_device rd;
std::mt19937 gen(rd());
std::mt19937 gen(0);
uniformDistribution<T2> distribution(rand_min, rand_max);
for (size_t i = 0; i < inputBlob->size(); i++) {
inputBlobData[i] = static_cast<T>(distribution(gen));

View File

@@ -212,6 +212,7 @@ def fill_blob_with_random(layer):
# np.random.uniform excludes high: add 1 to have it generated
if np.dtype(dtype).kind in ['i', 'u', 'b']:
rand_max += 1
rs = np.random.RandomState(np.random.MT19937(np.random.SeedSequence(0)))
if layer.shape:
return np.random.uniform(rand_min, rand_max, layer.shape).astype(dtype)
return (dtype)(np.random.uniform(rand_min, rand_max))
return rs.uniform(rand_min, rand_max, layer.shape).astype(dtype)
return (dtype)(rs.uniform(rand_min, rand_max))