Skip to content

Commit

Permalink
add epsilon to sum(pvalue) upperbound (apache#16211)
Browse files Browse the repository at this point in the history
  • Loading branch information
xidulu authored and larroy committed Sep 28, 2019
1 parent ac7d4d8 commit 1e50844
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/operator/numpy/random/np_multinomial_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void CheckPvalGPU(DType* input, int prob_length) {
DType sum = DType(0.0);
for (int i = 0; i < prob_length; ++i) {
sum += pvals_[i];
CHECK(sum <= DType(1.0))
CHECK(sum <= DType(1.0 + 1e-12))
<< "sum(pvals[:-1]) > 1.0";
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/numpy/random/np_multinomial_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void CheckPval(DType* input, int prob_length) {
DType sum = DType(0.0);
for (int i = 0; i < prob_length; ++i) {
sum += input[i];
CHECK_LE(sum, 1.0)
CHECK_LE(sum, 1.0 + 1e-12)
<< "sum(pvals[:-1]) > 1.0";
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ void NumpyMultinomialForward(const nnvm::NodeAttrs& attrs,
sum += param.pvals.value()[i];
// copy the tuple to data for later kernel usage
pvals_[i] = param.pvals.value()[i];
CHECK_LE(sum, 1.0)
CHECK_LE(sum, 1.0 + 1e-12)
<< "sum(pvals[:-1]) > 1.0";
}
Kernel<multinomial_kernel, xpu>::Launch(
Expand Down

0 comments on commit 1e50844

Please sign in to comment.