CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
438 lines
14 KiB
C++
438 lines
14 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "half_precision_common.hh"
|
|
#include "casting_common.hh"
|
|
|
|
/**
|
|
* @addtogroup HalfPrecisionCastingIntTypes HalfPrecisionCastingIntTypes
|
|
* @{
|
|
* @ingroup MathTest
|
|
*/
|
|
|
|
#define CAST_INT2HALF_RN_TEST_DEF(kern_name, T) \
|
|
CAST_KERNEL_DEF(kern_name, Float16, T) \
|
|
CAST_REF_DEF(kern_name, Float16, T) \
|
|
\
|
|
HIP_TEST_CASE(Unit_Device_##kern_name##_Accuracy_Positive) { \
|
|
Float16 (*ref)(T) = kern_name##_ref; \
|
|
CastIntRangeTest(kern_name##_kernel, ref, EqValidatorBuilderFactory<Float16>()); \
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__int2half_rn` for all possible inputs. The results are compared against
|
|
* reference function which performs int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__int2half_rn, int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__int2half_rz` for all possible inputs. The results are compared against
|
|
* reference function which performs int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__int2half_rz, int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__int2half_rd` for all possible inputs. The results are compared against
|
|
* reference function which performs int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__int2half_rd, int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__int2half_ru` for all possible inputs. The results are compared against
|
|
* reference function which performs int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__int2half_ru, int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__uint2half_rn` for all possible inputs. The results are compared against
|
|
* reference function which performs unsigned int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__uint2half_rn, unsigned int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__uint2half_rz` for all possible inputs. The results are compared against
|
|
* reference function which performs unsigned int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__uint2half_rz, unsigned int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__uint2half_rd` for all possible inputs. The results are compared against
|
|
* reference function which performs unsigned int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__uint2half_rd, unsigned int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__uint2half_ru` for all possible inputs. The results are compared against
|
|
* reference function which performs unsigned int cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__uint2half_ru, unsigned int)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__short2half_rn` for all possible inputs. The results are compared
|
|
* against reference function which performs short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__short2half_rn, short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__short2half_rz` for all possible inputs. The results are compared
|
|
* against reference function which performs short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__short2half_rz, short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__short2half_rd` for all possible inputs. The results are compared
|
|
* against reference function which performs short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__short2half_rd, short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__short2half_ru` for all possible inputs. The results are compared
|
|
* against reference function which performs short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__short2half_ru, short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ushort2half_rn` for all possible inputs. The results are compared
|
|
* against reference function which performs unsigned short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rn, unsigned short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ushort2half_rz` for all possible inputs. The results are compared
|
|
* against reference function which performs unsigned short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rz, unsigned short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ushort2half_rd` for all possible inputs. The results are compared
|
|
* against reference function which performs unsigned short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rd, unsigned short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ushort2half_ru` for all possible inputs. The results are compared
|
|
* against reference function which performs unsigned short cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_INT2HALF_RN_TEST_DEF(__ushort2half_ru, unsigned short)
|
|
|
|
#define CAST_LL2HALF_TEST_DEF(kern_name, T) \
|
|
CAST_KERNEL_DEF(kern_name, Float16, T) \
|
|
CAST_REF_DEF(kern_name, Float16, T) \
|
|
\
|
|
HIP_TEST_CASE(Unit_Device_##kern_name##_Accuracy_Positive) { \
|
|
Float16 (*ref)(T) = kern_name##_ref; \
|
|
CastIntBruteForceTest(kern_name##_kernel, ref, EqValidatorBuilderFactory<Float16>()); \
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ll2half_rn` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ll2half_rn, long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ll2half_rz` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ll2half_rz, long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ll2half_rd` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ll2half_rd, long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ll2half_ru` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ll2half_ru, long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ull2half_rn` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs unsigned long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ull2half_rn, unsigned long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ull2half_rz` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs unsigned long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ull2half_rz, unsigned long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ull2half_rd` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs unsigned long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ull2half_rd, unsigned long long)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ull2half_ru` against a large number of randomly generated values. The
|
|
* results are compared against reference function which performs unsigned long long cast to __half.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
CAST_LL2HALF_TEST_DEF(__ull2half_ru, unsigned long long)
|
|
|
|
CAST_KERNEL_DEF(__short_as_half, Float16, short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__short_as_half` for all possible inputs. The results are compared
|
|
* against reference function which performs copy of short value to __half variable.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device___short_as_half_Accuracy_Positive) {
|
|
Float16 (*ref)(short) = type2_as_type1_ref<Float16, short>;
|
|
CastIntBruteForceTest(__short_as_half_kernel, ref, EqValidatorBuilderFactory<Float16>());
|
|
}
|
|
|
|
CAST_KERNEL_DEF(__ushort_as_half, Float16, unsigned short)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests that checks `__ushort_as_half` for all possible inputs. The results are compared
|
|
* against reference function which performs copy of unsigned short value to __half variable.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/casting_int2half_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device___ushort_as_half_Accuracy_Positive) {
|
|
Float16 (*ref)(unsigned short) = type2_as_type1_ref<Float16, unsigned short>;
|
|
CastIntBruteForceTest(__ushort_as_half_kernel, ref, EqValidatorBuilderFactory<Float16>());
|
|
}
|
|
|
|
/**
|
|
* End doxygen group MathTest.
|
|
* @}
|
|
*/
|