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
722 lines
33 KiB
C++
722 lines
33 KiB
C++
/*******************************************************************************
|
|
*
|
|
* MIT License
|
|
*
|
|
* Copyright (C) 2022-2024 Advanced Micro Devices, Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
*******************************************************************************/
|
|
|
|
/* =====================================================================
|
|
Google Near check: ASSERT_NEAR( elementof(A), elementof(B))
|
|
=================================================================== */
|
|
|
|
/*!\file
|
|
* \brief compares two results (usually, CPU and GPU results); provides Google Near check.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "hipBuffer.hpp"
|
|
#include "hipblaslt_math.hpp"
|
|
#include "hipblaslt_ostream.hpp"
|
|
#include "hipblaslt_test.hpp"
|
|
#include "hipblaslt_vector.hpp"
|
|
#include <cmath>
|
|
#include <hipblaslt/hipblaslt.h>
|
|
|
|
#ifdef GOOGLE_TEST
|
|
/*! Compare CPU vs GPU scalars for near_check. GTest ASSERT_NEAR(inf, inf) is ill-formed
|
|
* because inf - inf is NaN; treat matching NaN and same-signed infinities as equal. */
|
|
inline void hipblaslt_near_compare_double(double a, double b, double abs_err)
|
|
{
|
|
if(std::isfinite(a) && std::isfinite(b))
|
|
ASSERT_NEAR(a, b, abs_err);
|
|
else if(std::isnan(a) || std::isnan(b))
|
|
ASSERT_TRUE(std::isnan(a) && std::isnan(b));
|
|
else
|
|
ASSERT_TRUE(std::isinf(a) && std::isinf(b) && (a == b));
|
|
}
|
|
#endif
|
|
|
|
template <class Tc, class Ti, class To>
|
|
static constexpr double sum_error_tolerance_for_gfx11 = std::numeric_limits<Tc>::epsilon();
|
|
|
|
template <>
|
|
constexpr double sum_error_tolerance_for_gfx11<float, hip_bfloat16, float> = 1 / 10.0;
|
|
|
|
template <>
|
|
constexpr double sum_error_tolerance_for_gfx11<float, hip_bfloat16, hip_bfloat16> = 1 / 10.0;
|
|
|
|
template <>
|
|
constexpr double sum_error_tolerance_for_gfx11<float, hipblasLtHalf, float> = 1 / 100.0;
|
|
|
|
template <>
|
|
constexpr double sum_error_tolerance_for_gfx11<float, hipblasLtHalf, hipblasLtHalf> = 1 / 100.0;
|
|
|
|
template <>
|
|
constexpr double sum_error_tolerance_for_gfx11<hipblasLtHalf, hipblasLtHalf, hipblasLtHalf>
|
|
= 1 / 100.0;
|
|
|
|
double sum_error_tolerance_for_gfx11_type(hipDataType Tc, hipDataType Ti, hipDataType To)
|
|
{
|
|
if(Tc == HIP_R_32F && Ti == HIP_R_16BF && (To == HIP_R_32F || To == HIP_R_16BF))
|
|
return 1 / 10.0;
|
|
else if(Tc == HIP_R_32F && Ti == HIP_R_16F && (To == HIP_R_32F || To == HIP_R_16F))
|
|
return 1 / 100.0;
|
|
else if(Tc == HIP_R_16F && Ti == HIP_R_16F && To == HIP_R_16F)
|
|
return 1 / 100.0;
|
|
else
|
|
{
|
|
switch(Tc)
|
|
{
|
|
case HIP_R_32F:
|
|
return std::numeric_limits<float>::epsilon();
|
|
case HIP_R_64F:
|
|
return std::numeric_limits<double>::epsilon();
|
|
case HIP_C_32F:
|
|
return std::numeric_limits<float>::epsilon();
|
|
case HIP_C_64F:
|
|
return std::numeric_limits<double>::epsilon();
|
|
case HIP_R_16F:
|
|
return std::numeric_limits<hipblasLtHalf>::epsilon();
|
|
case HIP_R_32I:
|
|
return std::numeric_limits<int32_t>::epsilon();
|
|
default:
|
|
hipblaslt_cerr << "Error type in sum_error_tolerance_for_gfx11_type" << std::endl;
|
|
return 0.0;
|
|
}
|
|
}
|
|
};
|
|
|
|
#ifndef GOOGLE_TEST
|
|
#define NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, err, NEAR_ASSERT)
|
|
#define NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, err, NEAR_ASSERT)
|
|
#else
|
|
|
|
#define NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, err, NEAR_ASSERT) \
|
|
do \
|
|
{ \
|
|
for(size_t k = 0; k < batch_count; k++) \
|
|
for(size_t j = 0; j < N; j++) \
|
|
for(size_t i = 0; i < M; i++) \
|
|
NEAR_ASSERT(hCPU[i + j * size_t(lda) + k * strideA], \
|
|
hGPU[i + j * size_t(lda) + k * strideA], \
|
|
err); \
|
|
} while(0)
|
|
|
|
#define NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, err, NEAR_ASSERT) \
|
|
do \
|
|
{ \
|
|
for(size_t k = 0; k < batch_count; k++) \
|
|
for(size_t j = 0; j < N; j++) \
|
|
for(size_t i = 0; i < M; i++) \
|
|
if(hipblaslt_isnan(hCPU[k][i + j * size_t(lda)])) \
|
|
{ \
|
|
ASSERT_TRUE(hipblaslt_isnan(hGPU[k][i + j * size_t(lda)])); \
|
|
} \
|
|
else \
|
|
{ \
|
|
NEAR_ASSERT( \
|
|
hCPU[k][i + j * size_t(lda)], hGPU[k][i + j * size_t(lda)], err); \
|
|
} \
|
|
} while(0)
|
|
|
|
#endif
|
|
|
|
#ifdef GOOGLE_TEST
|
|
#define NEAR_ASSERT_HALF(a, b, err) \
|
|
hipblaslt_near_compare_double(static_cast<double>(a), static_cast<double>(b), (err))
|
|
|
|
#define NEAR_ASSERT_BF16(a, b, err) \
|
|
hipblaslt_near_compare_double(static_cast<double>(a), static_cast<double>(b), (err))
|
|
|
|
#define NEAR_ASSERT_FP8(a, b, err) \
|
|
hipblaslt_near_compare_double(static_cast<double>(float(a)), static_cast<double>(float(b)), (err))
|
|
|
|
#define HIPBLASLT_NEAR_ASSERT_NEAR_PAIR(a, b, err) \
|
|
hipblaslt_near_compare_double(static_cast<double>(a), static_cast<double>(b), (err))
|
|
|
|
#define NEAR_ASSERT_COMPLEX_FLOAT(a, b, err) \
|
|
do \
|
|
{ \
|
|
auto ta = (a), tb = (b); \
|
|
hipblaslt_near_compare_double(std::real(ta), std::real(tb), (err)); \
|
|
hipblaslt_near_compare_double(std::imag(ta), std::imag(tb), (err)); \
|
|
} while(0)
|
|
#else
|
|
#define NEAR_ASSERT_HALF(a, b, err) ASSERT_NEAR(double(a), double(b), err)
|
|
|
|
#define NEAR_ASSERT_BF16(a, b, err) ASSERT_NEAR(double(a), double(b), err)
|
|
|
|
#define NEAR_ASSERT_FP8(a, b, err) ASSERT_NEAR(double(float(a)), double(float(b)), err)
|
|
|
|
#define HIPBLASLT_NEAR_ASSERT_NEAR_PAIR(a, b, err) ASSERT_NEAR((a), (b), (err))
|
|
|
|
#define NEAR_ASSERT_COMPLEX_FLOAT(a, b, err) \
|
|
do \
|
|
{ \
|
|
auto ta = (a); \
|
|
auto tb = (b); \
|
|
ASSERT_NEAR(std::real(ta), std::real(tb), err); \
|
|
ASSERT_NEAR(std::imag(ta), std::imag(tb), err); \
|
|
} while(0)
|
|
#endif
|
|
|
|
#define NEAR_ASSERT_COMPLEX_DOUBLE(a, b, err) \
|
|
do \
|
|
{ \
|
|
auto ta = (a); \
|
|
auto tb = (b); \
|
|
ASSERT_NEAR(std::real(ta), std::real(tb), err); \
|
|
ASSERT_NEAR(std::imag(ta), std::imag(tb), err); \
|
|
} while(0)
|
|
|
|
// Renamed macro to avoid conflict with complex<float>
|
|
#define NEAR_ASSERT_float(a, b, err) ASSERT_NEAR(a, b, err)
|
|
#define NEAR_ASSERT_double(a, b, err) ASSERT_NEAR(a, b, err)
|
|
|
|
// TODO: Replace std::remove_cv_t with std::type_identity_t in C++20
|
|
// It is only used to make T_hpa non-deduced
|
|
template <typename T, typename T_hpa = T>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const std::remove_cv_t<T_hpa>* hCPU,
|
|
const T* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, HIPBLASLT_NEAR_ASSERT_NEAR_PAIR);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblasLtHalf* hCPU,
|
|
const hipblasLtHalf* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_HALF);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hip_bfloat16, float>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const float* hCPU,
|
|
const hip_bfloat16* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_BF16);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_f8_fnuz* hCPU,
|
|
const hipblaslt_f8_fnuz* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_bf8_fnuz* hCPU,
|
|
const hipblaslt_bf8_fnuz* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_f8* hCPU,
|
|
const hipblaslt_f8* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_bf8* hCPU,
|
|
const hipblaslt_bf8* hGPU,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, 0, hCPU, hGPU, 1, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <typename T, typename T_hpa = T>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const std::remove_cv_t<T_hpa>* hCPU,
|
|
const T* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, HIPBLASLT_NEAR_ASSERT_NEAR_PAIR);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const hipblasLtHalf* hCPU,
|
|
const hipblasLtHalf* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_HALF);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hip_bfloat16, float>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const float* hCPU,
|
|
const hip_bfloat16* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_BF16);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const hipblaslt_f8_fnuz* hCPU,
|
|
const hipblaslt_f8_fnuz* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const hipblaslt_bf8_fnuz* hCPU,
|
|
const hipblaslt_bf8_fnuz* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const hipblaslt_f8* hCPU,
|
|
const hipblaslt_f8* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const hipblaslt_bf8* hCPU,
|
|
const hipblaslt_bf8* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const std::complex<float>* hCPU,
|
|
const std::complex<float>* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_COMPLEX_FLOAT);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
const std::complex<double>* hCPU,
|
|
const std::complex<double>* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK(M, N, lda, strideA, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_COMPLEX_DOUBLE);
|
|
}
|
|
|
|
|
|
template <typename T, typename T_hpa = T>
|
|
void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<std::remove_cv_t<T_hpa>> hCPU[],
|
|
const host_vector<T> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, HIPBLASLT_NEAR_ASSERT_NEAR_PAIR);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hipblasLtHalf>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<hipblasLtHalf> hCPU[],
|
|
const host_vector<hipblasLtHalf> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_HALF);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hip_bfloat16, float>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<float> hCPU[],
|
|
const host_vector<hip_bfloat16> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_BF16);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hipblaslt_f8_fnuz>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<hipblaslt_f8_fnuz> hCPU[],
|
|
const host_vector<hipblaslt_f8_fnuz> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hipblaslt_bf8_fnuz>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<hipblaslt_bf8_fnuz> hCPU[],
|
|
const host_vector<hipblaslt_bf8_fnuz> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hipblaslt_f8>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<hipblaslt_f8> hCPU[],
|
|
const host_vector<hipblaslt_f8> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hipblaslt_bf8>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<hipblaslt_bf8> hCPU[],
|
|
const host_vector<hipblaslt_bf8> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<std::complex<float>>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<std::complex<float>> hCPU[],
|
|
const host_vector<std::complex<float>> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_COMPLEX_FLOAT);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<std::complex<double>>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const host_vector<std::complex<double>> hCPU[],
|
|
const host_vector<std::complex<double>> hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_COMPLEX_DOUBLE);
|
|
}
|
|
|
|
|
|
template <typename T, typename T_hpa = T>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const std::remove_cv_t<T_hpa>* const hCPU[],
|
|
const T* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, HIPBLASLT_NEAR_ASSERT_NEAR_PAIR);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblasLtHalf* const hCPU[],
|
|
const hipblasLtHalf* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_HALF);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general<hip_bfloat16, float>(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const float* const hCPU[],
|
|
const hip_bfloat16* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_BF16);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_f8_fnuz* const hCPU[],
|
|
const hipblaslt_f8_fnuz* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_bf8_fnuz* const hCPU[],
|
|
const hipblaslt_bf8_fnuz* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_f8* const hCPU[],
|
|
const hipblaslt_f8* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
template <>
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
const hipblaslt_bf8* const hCPU[],
|
|
const hipblaslt_bf8* const hGPU[],
|
|
int64_t batch_count,
|
|
double abs_error)
|
|
{
|
|
NEAR_CHECK_B(M, N, lda, hCPU, hGPU, batch_count, abs_error, NEAR_ASSERT_FP8);
|
|
}
|
|
|
|
inline void near_check_general(int64_t M,
|
|
int64_t N,
|
|
int64_t lda,
|
|
int64_t strideA,
|
|
void* hCPU,
|
|
void* hGPU,
|
|
int64_t batch_count,
|
|
double abs_error,
|
|
hipDataType type)
|
|
{
|
|
switch(type)
|
|
{
|
|
case HIP_R_32F:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<float*>(hCPU),
|
|
static_cast<float*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_64F:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<double*>(hCPU),
|
|
static_cast<double*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_C_32F:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<std::complex<float>*>(hCPU),
|
|
static_cast<std::complex<float>*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_C_64F:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<std::complex<double>*>(hCPU),
|
|
static_cast<std::complex<double>*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_16F:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblasLtHalf*>(hCPU),
|
|
static_cast<hipblasLtHalf*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_16BF:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hip_bfloat16*>(hCPU),
|
|
static_cast<hip_bfloat16*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_8F_E4M3_FNUZ:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblaslt_f8_fnuz*>(hCPU),
|
|
static_cast<hipblaslt_f8_fnuz*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_8F_E5M2_FNUZ:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblaslt_bf8_fnuz*>(hCPU),
|
|
static_cast<hipblaslt_bf8_fnuz*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_8F_E4M3:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblaslt_f8*>(hCPU),
|
|
static_cast<hipblaslt_f8*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_8F_E5M2:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblaslt_bf8*>(hCPU),
|
|
static_cast<hipblaslt_bf8*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_32I:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<int32_t*>(hCPU),
|
|
static_cast<int32_t*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
case HIP_R_8I:
|
|
near_check_general(M,
|
|
N,
|
|
lda,
|
|
strideA,
|
|
static_cast<hipblasLtInt8*>(hCPU),
|
|
static_cast<hipblasLtInt8*>(hGPU),
|
|
batch_count,
|
|
abs_error);
|
|
break;
|
|
default:
|
|
hipblaslt_cerr << "Error type in near_check_general" << std::endl;
|
|
break;
|
|
}
|
|
} |