Files
TheRock/rocm-libraries/dnn-providers/miopen-provider/tests/common/TestWorkarounds.hpp
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

101 lines
5.2 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
// Test-side workarounds for known MIOpen-provider issues. Each macro is keyed
// by the upstream issue number so it is easy to grep and remove once the
// underlying problem is fixed.
//
// ----------------------------------------------------------------------------
// ROCm/rocm-libraries#6979 — MIOpen Conv-Bias-Activation (CBA) fusion has
// limited solver coverage (gfx90a returns wrong results, gfx1151 / RDNA archs
// have no CK fusion kernels). CBA-specific tests must skip when the engine
// search returns no applicable solution on the current device.
//
// IS_WORKAROUND_ISSUE_6979(result) — predicate that returns true when the
// `hipdnn_frontend::Error` from an engine-config-querying frontend call
// (`Graph::build()`, `get_ranked_engine_ids()`, `create_execution_plan*()`)
// indicates this issue. Use ONLY in CBA-specific tests; pair with
// `ASSERT_EQ(..., OK)` (or equivalent) so other failures still surface.
//
// Preferred call site is the `shouldSkipOnEngineConfigResult` override in a
// CBA-specific subclass of `IntegrationGraphVerificationHarness`. The
// override returns `WORKAROUND_ISSUE_6979_SKIP_MSG` (wrapped in
// `std::optional<std::string>`) when the predicate matches and
// `std::nullopt` otherwise; the harness body emits `GTEST_SKIP()` with that
// message. This keeps the base harness free of workaround logic.
//
// SKIP_IF_WORKAROUND_ISSUE_6979(result) — convenience wrapper that emits
// `GTEST_SKIP()` directly. Use only in test bodies that are NOT routed through
// the harness hook (e.g., `IntegrationGpuDeterministic.cpp`, where the test
// fixture inherits from a different base).
//
// Do NOT use in non-CBA tests — `GRAPH_NOT_SUPPORTED` outside the CBA path
// would indicate a real regression, not a known capability gap.
//
// To remove after the fix: delete this header alongside the production-side
// `Workarounds.hpp`, drop includes, and remove all macro call sites.
// `git grep WORKAROUND_ISSUE_6979` finds them all.
//
// `<hipdnn_frontend.hpp>` is header-only, so this header has no linkage
// dependency on the provider's compiled object files — it remains usable from
// integration_tests, which only loads the plugin via dlopen.
// ----------------------------------------------------------------------------
#include <hipdnn_frontend.hpp>
#include <gtest/gtest.h>
// Single source for the issue-6979 skip message — referenced by both SKIP
// macros so wording stays in sync.
#define WORKAROUND_ISSUE_6979_SKIP_MSG \
"[#6979] Skipping due to ROCm/rocm-libraries#6979 (no engine has an applicable " \
"solution for ConvBiasActiv fusion on the current device)"
// Inline function (not a macro) so the argument is evaluated exactly once.
// Name kept in IS_WORKAROUND_ISSUE_* form so `git grep WORKAROUND_ISSUE_6979`
// finds every site.
// NOLINTNEXTLINE(readability-identifier-naming)
inline bool IS_WORKAROUND_ISSUE_6979(const hipdnn_frontend::Error& result)
{
return result.get_code() == hipdnn_frontend::ErrorCode::GRAPH_NOT_SUPPORTED;
}
#define SKIP_IF_WORKAROUND_ISSUE_6979(result) \
do \
{ \
const auto& _skip_result_6979 = (result); \
if(IS_WORKAROUND_ISSUE_6979(_skip_result_6979)) \
{ \
GTEST_SKIP() << WORKAROUND_ISSUE_6979_SKIP_MSG << ": " \
<< _skip_result_6979.get_message(); \
} \
} while(0)
// SKIP_IF_NO_APPLICABLE_CBA_ENGINE(handle, planBuilder, graph) -- for unit
// tests that build a CBA plan directly. Queries `isApplicable()` on the
// caller's actual test graph and emits `GTEST_SKIP()` when no solver is
// available on the current device -- before any state is mutated by
// `buildPlan()` or the plan constructor.
//
// IMPORTANT: this macro assumes the caller passes a known-VALID CBA graph
// (typically built via `createValidConvFwdActivGraph` /
// `createValidConvFwdBiasActivGraph` from FlatbufferGraphTestUtils). An
// invalid graph also reports `isApplicable() == false` and would skip
// silently rather than fail. Validity is the caller's responsibility; the
// macro does not (and intentionally cannot) distinguish "device cannot run
// this CBA" from "this graph is malformed."
//
// In parametric tests where some cases expect non-applicability (e.g.
// "Unsupported layout WHCN"), guard the call with `if(<expected applicable>)`
// so negative cases still run and validate the rejection assertion.
#define SKIP_IF_NO_APPLICABLE_CBA_ENGINE(handle, planBuilder, graph) \
do \
{ \
if(!(planBuilder).isApplicable((handle), (graph))) \
{ \
GTEST_SKIP() << WORKAROUND_ISSUE_6979_SKIP_MSG; \
} \
} while(0)