Added a test to validate the fallback path for half floats

This commit is contained in:
Benoit Steiner 2016-03-18 12:02:39 -07:00
parent 9a7ece9caf
commit dd514de8a9

View File

@ -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()
{
CALL_SUBTEST(test_cuda_conversion());
CALL_SUBTEST(test_fallback_conversion());
}