-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: AVX support for exp/log for strided float32 arrays #13581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
from numpy.testing import ( | ||
assert_, assert_equal, assert_raises, assert_raises_regex, | ||
assert_array_equal, assert_almost_equal, assert_array_almost_equal, | ||
assert_allclose, assert_no_warnings, suppress_warnings, | ||
assert_array_max_ulp, assert_allclose, assert_no_warnings, suppress_warnings, | ||
_gen_alignment_data | ||
) | ||
|
||
|
@@ -678,6 +678,31 @@ def test_log_values(self): | |
assert_raises(FloatingPointError, np.log, np.float32(-np.inf)) | ||
assert_raises(FloatingPointError, np.log, np.float32(-1.0)) | ||
|
||
class TestExpLogFloat32(object): | ||
def test_exp_float32(self): | ||
np.random.seed(42) | ||
x_f32 = np.float32(np.random.uniform(low=0.0,high=88.1,size=1000000)) | ||
x_f64 = np.float64(x_f32) | ||
assert_array_max_ulp(np.exp(x_f32), np.float32(np.exp(x_f64)), maxulp=2.6) | ||
|
||
def test_log_float32(self): | ||
np.random.seed(42) | ||
x_f32 = np.float32(np.random.uniform(low=0.0,high=1000,size=1000000)) | ||
x_f64 = np.float64(x_f32) | ||
assert_array_max_ulp(np.log(x_f32), np.float32(np.log(x_f64)), maxulp=3.9) | ||
|
||
def test_strided_exp_log_float32(self): | ||
np.random.seed(42) | ||
strides = np.random.randint(low=-100, high=100, size=100) | ||
sizes = np.random.randint(low=1, high=2000, size=100) | ||
for ii in sizes: | ||
x_f32 = np.float32(np.random.uniform(low=0.01,high=88.1,size=ii)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. denormal floats are excluded here. how is the accuracy for these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are meant to be like a sanity check and are not comprehensive at all. It will be slow to test for a large sample of float32's. But the MAXULP error of 2.6 and 3.9 hold even for denormals (this is something I validated separately by enumerating all float32 numbers). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok thanks |
||
exp_true = np.exp(x_f32) | ||
log_true = np.log(x_f32) | ||
for jj in strides: | ||
assert_equal(np.exp(x_f32[::jj]), exp_true[::jj]) | ||
assert_equal(np.log(x_f32[::jj]), log_true[::jj]) | ||
|
||
class TestLogAddExp(_FilterInvalids): | ||
def test_logaddexp_values(self): | ||
x = [1, 2, 3, 4, 5] | ||
|
Uh oh!
There was an error while loading. Please reload this page.