-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
@eric-haibin-lin @rahul003 @reminisce @anirudh2290 This is bug fix for #9062, please give a review if you have a minute. Thanks! |
tests/python/unittest/test_random.py
Outdated
freq = np.bincount(y[i,:], minlength=5)/np.float32(samples)*x[i,:].sum() | ||
mx.test_utils.assert_almost_equal(freq, x[i], rtol=0.20) | ||
rprob = x[i][y[i]]/x[i].sum() | ||
mx.test_utils.assert_almost_equal(np.log(rprob), prob.asnumpy()[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we provide specific atol ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the default not 1e-20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current test can always pass, I guess the default 1e-20 value should be okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should provide atol
to avoid failure when comparing two numbers that are close to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks!
tests/python/unittest/test_random.py
Outdated
real_dx = np.zeros((5,)) | ||
for j in range(samples): | ||
real_dx[y[i][j]] += 5.0 / rprob[j] | ||
mx.test_utils.assert_almost_equal(real_dx, dx[i, :], rtol=1e-4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question as above.
* fix typo in sample_multinomial_op.h (issue apache#9062) * add test case for 1D prob input case
* fix typo in sample_multinomial_op.h (issue apache#9062) * add test case for 1D prob input case
Description
Bug fix for issue #9062
Checklist
Essentials
Changes