Files
TheRock/rocm-libraries/projects/hipdnn/tests/frontend/IntegrationGraphSupportCheck.cpp
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

145 lines
5.0 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <hipdnn_frontend.hpp>
#include <hipdnn_test_sdk/utilities/FrontendGraphFactory.hpp>
#include <hipdnn_test_sdk/utilities/TestUtilities.hpp>
#include <test_plugins/TestPluginConstants.hpp>
using namespace hipdnn_frontend;
using namespace hipdnn_frontend::graph;
using hipdnn_test_sdk::utilities::FrontendGraphFactory;
using hipdnn_test_sdk::utilities::OperationType;
namespace
{
class IntegrationGraphSupportCheck : public ::testing::Test
{
protected:
void SetUp() override
{
// is_supported_ext drives finalize(), which reads the device from the
// handle's stream — bind a real one and skip on no-GPU runners.
SKIP_IF_NO_DEVICES();
loadPlugins({hipdnn_tests::plugin_constants::testGoodPluginPath().c_str()});
ASSERT_EQ(hipdnnCreate(&_handle), HIPDNN_STATUS_SUCCESS);
ASSERT_EQ(hipStreamCreate(&_stream), hipSuccess);
ASSERT_EQ(hipdnnSetStream(_handle, _stream), HIPDNN_STATUS_SUCCESS);
}
void TearDown() override
{
if(_handle != nullptr)
{
ASSERT_EQ(hipdnnDestroy(_handle), HIPDNN_STATUS_SUCCESS);
}
if(_stream != nullptr)
{
ASSERT_EQ(hipStreamDestroy(_stream), hipSuccess);
_stream = nullptr;
}
}
static void loadPlugins(std::initializer_list<const char*> pluginPaths)
{
const std::vector<const char*> paths(pluginPaths);
ASSERT_EQ(hipdnnSetEnginePluginPaths_ext(
paths.size(), paths.data(), HIPDNN_PLUGIN_LOADING_ABSOLUTE),
HIPDNN_STATUS_SUCCESS);
}
void recreateHandleWithPlugins(std::initializer_list<const char*> pluginPaths)
{
ASSERT_EQ(hipdnnDestroy(_handle), HIPDNN_STATUS_SUCCESS);
_handle = nullptr;
loadPlugins(pluginPaths);
ASSERT_EQ(hipdnnCreate(&_handle), HIPDNN_STATUS_SUCCESS);
ASSERT_EQ(hipdnnSetStream(_handle, _stream), HIPDNN_STATUS_SUCCESS);
}
hipdnnHandle_t _handle = nullptr;
hipStream_t _stream = nullptr;
};
TEST_F(IntegrationGraphSupportCheck, SupportedWithGoodPlugin)
{
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
auto result = graph.is_supported_ext(_handle);
EXPECT_TRUE(result.is_good()) << result.get_message();
}
TEST_F(IntegrationGraphSupportCheck, NotSupportedWhenNoApplicableEngines)
{
recreateHandleWithPlugins(
{hipdnn_tests::plugin_constants::testNoApplicableEnginesAPluginPath().c_str(),
hipdnn_tests::plugin_constants::testNoApplicableEnginesBPluginPath().c_str()});
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
auto result = graph.is_supported_ext(_handle);
EXPECT_FALSE(result.is_good()) << "Expected failure when no engines are applicable";
}
TEST_F(IntegrationGraphSupportCheck, SupportedWithMixedPlugins)
{
recreateHandleWithPlugins(
{hipdnn_tests::plugin_constants::testNoApplicableEnginesAPluginPath().c_str(),
hipdnn_tests::plugin_constants::testGoodPluginPath().c_str()});
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
auto result = graph.is_supported_ext(_handle);
EXPECT_TRUE(result.is_good()) << result.get_message();
}
TEST_F(IntegrationGraphSupportCheck, AutoBuildsGraphIfNotBuilt)
{
// Create graph but do NOT call validate() or build_operation_graph()
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
// is_supported_ext should auto-validate and auto-build
auto result = graph.is_supported_ext(_handle);
EXPECT_TRUE(result.is_good()) << result.get_message();
}
TEST_F(IntegrationGraphSupportCheck, SkipsBuildIfAlreadyBuilt)
{
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
// Explicitly validate and build first
auto result = graph.validate();
ASSERT_TRUE(result.is_good()) << result.get_message();
result = graph.build_operation_graph(_handle);
ASSERT_TRUE(result.is_good()) << result.get_message();
// is_supported_ext should work on a pre-built graph
result = graph.is_supported_ext(_handle);
EXPECT_TRUE(result.is_good()) << result.get_message();
}
TEST_F(IntegrationGraphSupportCheck, SupportedAfterIsSupportedDoesNotCorruptState)
{
Graph graph = FrontendGraphFactory::create(OperationType::CONV_FORWARD);
// First call is_supported_ext
auto result = graph.is_supported_ext(_handle);
ASSERT_TRUE(result.is_good()) << "is_supported_ext failed: " << result.get_message();
// Then proceed with full execution plan flow
result = graph.create_execution_plans();
ASSERT_TRUE(result.is_good()) << "create_execution_plans failed: " << result.get_message();
result = graph.check_support();
ASSERT_TRUE(result.is_good()) << "check_support failed: " << result.get_message();
result = graph.build_plans();
ASSERT_TRUE(result.is_good()) << "build_plans failed: " << result.get_message();
}
} // namespace