Skip to content

Commit

Permalink
fix "invalid min and max arguments for uniform_int" error (pytorch#282)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#282

I64Test will cause the above error when running in Debug mode,
caused by

  randFill(A, numeric_limits<int64_t>::lowest(), numeric_limits<int64_t>::max());

Calling uniform_int_distribution<int> will cast the above min, max
into int type on Windows in Debug mode, leading to
the above assertion error.

Reviewed By: jspark1105

Differential Revision: D19685537

fbshipit-source-id: 7c4ada46326dae6b61dc7794972192c0a0e9992e
  • Loading branch information
Hongzhang Shan authored and jspark1105 committed Mar 21, 2020
1 parent 2a881a1 commit defaa88
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bench/BenchUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ randFill<uint8_t>(aligned_vector<uint8_t>& vec, uint8_t low, uint8_t high);
template void
randFill<int8_t>(aligned_vector<int8_t>& vec, int8_t low, int8_t high);
template void randFill<int>(aligned_vector<int>& vec, int low, int high);
template void
randFill<int64_t>(aligned_vector<int64_t>& vec, int64_t low, int64_t high);
//template void
//randFill<int64_t>(aligned_vector<int64_t>& vec, int64_t low, int64_t high);
template <>
void randFill(aligned_vector<int64_t>& vec, int64_t low, int64_t high) {
std::uniform_int_distribution<int64_t> dis(low, high);
std::generate(vec.begin(), vec.end(), [&] { return dis(eng); });
}

void llc_flush(std::vector<char>& llc) {
volatile char* data = llc.data();
Expand Down

0 comments on commit defaa88

Please sign in to comment.