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
97 lines
3.3 KiB
C++
97 lines
3.3 KiB
C++
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// error_object construction, code mapping, and message
|
|
// preservation through the aliased hipdnn_frontend::Error, plus the re-exported
|
|
// error macros. The shim aliases the hipDNN error types 1:1 (no wrapper), so
|
|
// these assertions also pin that the alias is exact. Gated behind
|
|
// HIPDNN_ENABLE_CUDNN_COMPATIBILITY in the frontend tests CMakeLists.
|
|
#include <hipdnn_compatibility/cudnn/cudnn_frontend.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <type_traits>
|
|
|
|
namespace cfe = hipdnn_frontend::compatibility::cudnn_frontend;
|
|
|
|
// The error types must be the *same* types as hipDNN's, not parallel
|
|
// re-declarations (alias, do not wrap).
|
|
static_assert(std::is_same_v<cfe::error_t, hipdnn_frontend::error_t>,
|
|
"cudnn_frontend::error_t must alias hipdnn_frontend::error_t");
|
|
static_assert(std::is_same_v<cfe::error_object, hipdnn_frontend::error_object>,
|
|
"cudnn_frontend::error_object must alias hipdnn_frontend::error_object");
|
|
static_assert(std::is_same_v<cfe::error_code_t, hipdnn_frontend::error_code_t>,
|
|
"cudnn_frontend::error_code_t must alias hipdnn_frontend::error_code_t");
|
|
|
|
namespace
|
|
{
|
|
using cfe::error_code_t;
|
|
using cfe::error_object;
|
|
using cfe::error_t;
|
|
|
|
TEST(TestCudnnShimError, DefaultObjectIsOkAndGood)
|
|
{
|
|
const error_t e;
|
|
EXPECT_TRUE(e.is_good());
|
|
EXPECT_FALSE(e.is_bad());
|
|
EXPECT_EQ(e.get_code(), error_code_t::OK);
|
|
EXPECT_TRUE(e == error_code_t::OK);
|
|
}
|
|
|
|
TEST(TestCudnnShimError, PreservesCodeAndMessage)
|
|
{
|
|
const error_object e{error_code_t::GRAPH_NOT_SUPPORTED, "no engine accepted graph"};
|
|
EXPECT_TRUE(e.is_bad());
|
|
EXPECT_FALSE(e.is_good());
|
|
EXPECT_EQ(e.get_code(), error_code_t::GRAPH_NOT_SUPPORTED);
|
|
EXPECT_EQ(e.get_message(), "no engine accepted graph");
|
|
EXPECT_TRUE(e == error_code_t::GRAPH_NOT_SUPPORTED);
|
|
EXPECT_TRUE(e != error_code_t::OK);
|
|
}
|
|
|
|
// Because the shim error type *is* hipDNN's Error, a value produced on one side
|
|
// is read on the other with no conversion.
|
|
TEST(TestCudnnShimError, AliasInteroperatesWithHipdnnError)
|
|
{
|
|
const hipdnn_frontend::error_t native{error_code_t::INVALID_VALUE, "bad value"};
|
|
// Same type on both sides — a cudnn_frontend::error_t reference binds to a
|
|
// hipdnn_frontend::error_t with no conversion.
|
|
const error_t& aliased = native;
|
|
EXPECT_EQ(aliased.get_code(), error_code_t::INVALID_VALUE);
|
|
EXPECT_EQ(aliased.get_message(), "bad value");
|
|
}
|
|
|
|
// Helpers exercising the re-exported error macros.
|
|
error_t failsIfNegative(int x)
|
|
{
|
|
RETURN_CUDNN_FRONTEND_ERROR_IF(x < 0, error_code_t::INVALID_VALUE, "x must be >= 0");
|
|
return {};
|
|
}
|
|
|
|
error_t checkThenSucceed(int x)
|
|
{
|
|
CHECK_CUDNN_FRONTEND_ERROR(failsIfNegative(x));
|
|
return {};
|
|
}
|
|
|
|
TEST(TestCudnnShimError, ReturnErrorIfMacro)
|
|
{
|
|
auto bad = failsIfNegative(-1);
|
|
EXPECT_TRUE(bad.is_bad());
|
|
EXPECT_EQ(bad.get_code(), error_code_t::INVALID_VALUE);
|
|
EXPECT_EQ(bad.get_message(), "x must be >= 0");
|
|
|
|
EXPECT_TRUE(failsIfNegative(5).is_good());
|
|
}
|
|
|
|
TEST(TestCudnnShimError, CheckErrorMacroPropagates)
|
|
{
|
|
auto bad = checkThenSucceed(-1);
|
|
EXPECT_TRUE(bad.is_bad());
|
|
EXPECT_EQ(bad.get_code(), error_code_t::INVALID_VALUE);
|
|
|
|
EXPECT_TRUE(checkThenSucceed(2).is_good());
|
|
}
|
|
|
|
} // namespace
|