/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include "half_precision_common.hh" /** * @addtogroup HalfPrecisionMath HalfPrecisionMath * @{ * @ingroup MathTest */ MATH_UNARY_HP_KERNEL_DEF(hcos); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hcos(x)` for all possible inputs. The results are * compared against reference function `float std::cos(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hcos, static_cast(std::cos), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2cos); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2cos(x)` for all possible inputs. The results are * compared against reference function `float std::cos(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2cos, static_cast(std::cos), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hsin); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hsin(x)` for all possible inputs. The results are * compared against reference function `float std::sin(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hsin, static_cast(std::sin), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2sin); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2sin(x)` for all possible inputs. The results are * compared against reference function `float std::sin(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2sin, static_cast(std::sin), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hexp); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hexp(x)` for all possible inputs. The results are * compared against reference function `float std::exp(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hexp, static_cast(std::exp), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2exp); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2exp(x)` for all possible inputs. The results are * compared against reference function `float std::exp(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2exp, static_cast(std::exp), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hexp10); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hexp10(x)` for all possible inputs. The results are * compared against reference function `float exp10(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hexp10, static_cast(exp10f), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2exp10); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2exp10(x)` for all possible inputs. The results are * compared against reference function `float exp10(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2exp10, static_cast(exp10f), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hexp2); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hexp2(x)` for all possible inputs. The results are * compared against reference function `float std::exp2(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hexp2, static_cast(std::exp2), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2exp2); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2exp2(x)` for all possible inputs. The results are * compared against reference function `float std::exp2(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2exp2, static_cast(std::exp2), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hlog); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hlog(x)` for all possible inputs. The results are * compared against reference function `float std::log(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hlog, static_cast(std::log), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2log); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2log(x)` for all possible inputs. The results are * compared against reference function `float std::log(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2log, static_cast(std::log), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hlog10); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hlog10(x)` for all possible inputs. The results are * compared against reference function `float std::log10(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hlog10, static_cast(std::log10), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2log10); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2log10(x)` for all possible inputs. The results are * compared against reference function `float std::log10(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2log10, static_cast(std::log10), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hlog2); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hlog2(x)` for all possible inputs. The results are * compared against reference function `float std::log2(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hlog2, static_cast(std::log2), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2log2); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2log2(x)` for all possible inputs. The results are * compared against reference function `float std::log2(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2log2, static_cast(std::log2), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hsqrt); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hsqrt(x)` for all possible inputs. The results are * compared against reference function `float std::sqrt(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hsqrt, static_cast(std::sqrt), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(h2sqrt); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2sqrt(x)` for all possible inputs. The results are * compared against reference function `float std::sqrt(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2sqrt, static_cast(std::sqrt), ULPValidatorBuilderFactory(1)); MATH_UNARY_HP_KERNEL_DEF(hceil); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hceil(x)` for all possible inputs. The results are * compared against reference function `float std::ceil(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hceil, static_cast(std::ceil), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2ceil); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2ceil(x)` for all possible inputs. The results are * compared against reference function `float std::ceil(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2ceil, static_cast(std::ceil), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(hfloor); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hfloor(x)` for all possible inputs. The results are * compared against reference function `float std::floor(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hfloor, static_cast(std::floor), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2floor); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2floor(x)` for all possible inputs. The results are * compared against reference function `float std::floor(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2floor, static_cast(std::floor), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(htrunc); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `htrunc(x)` for all possible inputs. The results are * compared against reference function `float std::trunc(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(htrunc, static_cast(std::trunc), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2trunc); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2trunc(x)` for all possible inputs. The results are * compared against reference function `float std::trunc(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2trunc, static_cast(std::trunc), EqValidatorBuilderFactory()); static float hrcp_ref(float x) { return 1.0f / x; } MATH_UNARY_HP_KERNEL_DEF(hrcp); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hrcp(x)` for all possible inputs. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hrcp, hrcp_ref, EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2rcp); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2rcp(x)` for all possible inputs. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2rcp, hrcp_ref, EqValidatorBuilderFactory()); static float hrsqrt_ref(float x) { return 1.0f / std::sqrt(x); } MATH_UNARY_HP_KERNEL_DEF(hrsqrt); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hrsqrt(x)` for all possible inputs. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hrsqrt, hrsqrt_ref, EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2rsqrt); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2rsqrt(x)` for all possible inputs. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2rsqrt, hrsqrt_ref, EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(hrint); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `hrint(x)` for all possible inputs. The results are * compared against reference function `float std::rint(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(hrint, static_cast(std::rint), EqValidatorBuilderFactory()); MATH_UNARY_HP_KERNEL_DEF(h2rint); /** * Test Description * ------------------------ * - Tests the numerical accuracy of `h2rint(x)` for all possible inputs. The results are * compared against reference function `float std::rint(float)`. * * Test source * ------------------------ * - unit/math/half_precision_math.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ MATH_UNARY_HP_TEST_DEF_IMPL(h2rint, static_cast(std::rint), EqValidatorBuilderFactory()); /** * End doxygen group MathTest. * @} */