[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/arrayfire/arrayfire/master/test/half.cpp [Back]  [Original]

/*******************************************************
 * Copyright (c) 2019, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

#include 
#include 
#include 
#include 

#include 
#include 

using af::array;
using af::constant;
using af::half;
using std::vector;

TEST(Half, print) {
    SUPPORTED_TYPE_CHECK(af_half);
    array aa = af::constant(3.14, 3, 3, f16);
    array bb = af::constant(2, 3, 3, f16);
    af_print(aa);
}

struct convert_params {
    af_dtype from, to;
    double value;
    convert_params(af_dtype f, af_dtype t, double v)
        : from(f), to(t), value(v) {}
};

class HalfConvert : public ::testing::TestWithParam {};

INSTANTIATE_TEST_SUITE_P(ToF16, HalfConvert,
                         ::testing::Values(convert_params(f32, f16, 10),
                                           convert_params(f64, f16, 10),
                                           convert_params(s32, f16, 10),
                                           convert_params(u32, f16, 10),
                                           convert_params(s8, f16, 10),
                                           convert_params(u8, f16, 10),
                                           convert_params(s64, f16, 10),
                                           convert_params(u64, f16, 10),
                                           convert_params(s16, f16, 10),
                                           convert_params(u16, f16, 10),
                                           convert_params(f16, f16, 10)));

INSTANTIATE_TEST_SUITE_P(FromF16, HalfConvert,
                         ::testing::Values(convert_params(f16, f32, 10),
                                           convert_params(f16, f64, 10),
                                           convert_params(f16, s32, 10),
                                           convert_params(f16, u32, 10),
                                           convert_params(f16, s8, 10),
                                           convert_params(f16, u8, 10),
                                           convert_params(f16, s64, 10),
                                           convert_params(f16, u64, 10),
                                           convert_params(f16, s16, 10),
                                           convert_params(f16, u16, 10),
                                           convert_params(f16, f16, 10)));

TEST_P(HalfConvert, convert) {
    SUPPORTED_TYPE_CHECK(af_half);
    convert_params params = GetParam();
    if (noDoubleTests(params.to))
        GTEST_SKIP() 

Web Proxy Viewer  |  New URL  |  Original Page