Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Numpy] Fix numerical error in multinomial's pvalue check #16211

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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