Unverified Commit 1db4ad4f authored by nv-dlasalle's avatar nv-dlasalle Committed by GitHub
Browse files

Move pointer dereferencing in CDFSampler::draw() and AliasSampler::draw() to...


Move pointer dereferencing in CDFSampler::draw() and AliasSampler::draw() to inside of conditional (#2943)
Co-authored-by: default avatarQuan (Andy) Gan <coin2028@hotmail.com>
parent 66eb240d
...@@ -121,9 +121,9 @@ class AliasSampler: public BaseSampler<Idx> { ...@@ -121,9 +121,9 @@ class AliasSampler: public BaseSampler<Idx> {
~AliasSampler() {} ~AliasSampler() {}
Idx Draw() { Idx Draw() {
const DType *_prob_data = static_cast<DType *>(_prob->data);
DType avg = accum / N; DType avg = accum / N;
if (!replace) { if (!replace) {
const DType *_prob_data = static_cast<DType *>(_prob->data);
if (2 * taken >= accum) if (2 * taken >= accum)
Reconstruct(_prob); Reconstruct(_prob);
while (true) { while (true) {
...@@ -219,9 +219,9 @@ class CDFSampler: public BaseSampler<Idx> { ...@@ -219,9 +219,9 @@ class CDFSampler: public BaseSampler<Idx> {
~CDFSampler() {} ~CDFSampler() {}
Idx Draw() { Idx Draw() {
const DType *_prob_data = static_cast<DType *>(_prob->data);
DType eps = std::numeric_limits<DType>::min(); DType eps = std::numeric_limits<DType>::min();
if (!replace) { if (!replace) {
const DType *_prob_data = static_cast<DType *>(_prob->data);
if (2 * taken >= accum) if (2 * taken >= accum)
Reconstruct(_prob); Reconstruct(_prob);
while (true) { while (true) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment