mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Added a test to validate the fallback path for half floats
This commit is contained in:
parent
9a7ece9caf
commit
dd514de8a9
@ -59,7 +59,22 @@ void test_cuda_conversion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_fallback_conversion() {
|
||||||
|
int num_elem = 101;
|
||||||
|
Tensor<float, 1> floats(num_elem);
|
||||||
|
floats.setRandom();
|
||||||
|
|
||||||
|
Eigen::Tensor<Eigen::half, 1> halfs = floats.cast<Eigen::half>();
|
||||||
|
Eigen::Tensor<float, 1> conv = half.cast<float>();
|
||||||
|
|
||||||
|
for (int i = 0; i < num_elem; ++i) {
|
||||||
|
VERIFY_IS_APPROX(floats(i), conv(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_cxx11_tensor_cast_float16_cuda()
|
void test_cxx11_tensor_cast_float16_cuda()
|
||||||
{
|
{
|
||||||
CALL_SUBTEST(test_cuda_conversion());
|
CALL_SUBTEST(test_cuda_conversion());
|
||||||
|
CALL_SUBTEST(test_fallback_conversion());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user