mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix gpu special function tests.
Some checks used incorrect values, partly from copy-paste errors,
partly from the change in behaviour introduced in !398.
Modified results to match scipy, simplified tests by updating
`VERIFY_IS_CWISE_APPROX` to work for scalars.
(cherry picked from commit 701f5d1c91)
This commit is contained in:
@@ -681,8 +681,8 @@ void test_gpu_digamma()
|
||||
expected_out(2) = Scalar(1.2561176684318);
|
||||
expected_out(3) = Scalar(2.398239129535781);
|
||||
expected_out(4) = Scalar(9.210340372392849);
|
||||
expected_out(5) = std::numeric_limits<Scalar>::infinity();
|
||||
expected_out(6) = std::numeric_limits<Scalar>::infinity();
|
||||
expected_out(5) = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
expected_out(6) = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
|
||||
std::size_t bytes = in.size() * sizeof(Scalar);
|
||||
|
||||
@@ -704,11 +704,8 @@ void test_gpu_digamma()
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
assert(gpuStreamSynchronize(gpu_device.stream()) == gpuSuccess);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
VERIFY_IS_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
for (int i = 5; i < 7; ++i) {
|
||||
VERIFY_IS_EQUAL(out(i), expected_out(i));
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
VERIFY_IS_CWISE_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
|
||||
gpuFree(d_in);
|
||||
@@ -741,7 +738,7 @@ void test_gpu_zeta()
|
||||
expected_out(0) = std::numeric_limits<Scalar>::infinity();
|
||||
expected_out(1) = Scalar(1.61237534869);
|
||||
expected_out(2) = Scalar(0.234848505667);
|
||||
expected_out(3) = Scalar(1.03086757337e-5);
|
||||
expected_out(3) = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
expected_out(4) = Scalar(0.367879440865);
|
||||
expected_out(5) = Scalar(0.054102025820864097);
|
||||
|
||||
@@ -769,13 +766,8 @@ void test_gpu_zeta()
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
assert(gpuStreamSynchronize(gpu_device.stream()) == gpuSuccess);
|
||||
|
||||
VERIFY_IS_EQUAL(out(0), expected_out(0));
|
||||
VERIFY((std::isnan)(out(3)));
|
||||
|
||||
for (int i = 1; i < 6; ++i) {
|
||||
if (i != 3) {
|
||||
VERIFY_IS_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
VERIFY_IS_CWISE_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
|
||||
gpuFree(d_in_x);
|
||||
@@ -1117,13 +1109,8 @@ void test_gpu_ndtri()
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
assert(gpuStreamSynchronize(gpu_device.stream()) == gpuSuccess);
|
||||
|
||||
VERIFY_IS_EQUAL(out(0), expected_out(0));
|
||||
VERIFY((std::isnan)(out(3)));
|
||||
|
||||
for (int i = 1; i < 6; ++i) {
|
||||
if (i != 3) {
|
||||
VERIFY_IS_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
VERIFY_IS_CWISE_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
|
||||
gpuFree(d_in_x);
|
||||
@@ -1262,12 +1249,8 @@ void test_gpu_betainc()
|
||||
assert(gpuMemcpyAsync(out.data(), d_out, bytes, gpuMemcpyDeviceToHost, gpu_device.stream()) == gpuSuccess);
|
||||
assert(gpuStreamSynchronize(gpu_device.stream()) == gpuSuccess);
|
||||
|
||||
for (int i = 1; i < 125; ++i) {
|
||||
if ((std::isnan)(expected_out(i))) {
|
||||
VERIFY((std::isnan)(out(i)));
|
||||
} else {
|
||||
VERIFY_IS_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
for (int i = 0; i < 125; ++i) {
|
||||
VERIFY_IS_CWISE_APPROX(out(i), expected_out(i));
|
||||
}
|
||||
|
||||
gpuFree(d_in_x);
|
||||
|
||||
Reference in New Issue
Block a user