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

104 lines
3.4 KiB
C++

// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
// Integration test for autotune config file persistence round-trip.
// Autotunes to a JSON config file, then verifies the config can be loaded
// via HIPDNN_HEUR_CONFIG_PATH to rebuild and execute the graph.
#include <filesystem>
#include <gtest/gtest.h>
#include <hip/hip_runtime.h>
#include <memory>
#include <unordered_map>
#include <vector>
#include <hipdnn_data_sdk/utilities/PlatformUtils.hpp>
#include <hipdnn_data_sdk/utilities/Workspace.hpp>
#include <hipdnn_frontend.hpp>
#include "AutotuneIntegrationFixture.hpp"
using namespace hipdnn_frontend;
using namespace hipdnn_frontend::graph;
using namespace hipdnn_data_sdk::utilities;
namespace
{
class IntegrationAutotunePersistence : public hipdnn_tests::AutotuneIntegrationFixture
{
protected:
void TearDown() override
{
// Clean up temp config file if it exists
std::error_code ec;
std::filesystem::remove(_configFile, ec);
// Ensure the env var is always cleared
hipdnn_data_sdk::utilities::unsetEnv("HIPDNN_HEUR_CONFIG_PATH");
AutotuneIntegrationFixture::TearDown();
}
std::filesystem::path _configFile
= std::filesystem::temp_directory_path() / "test_autotune_persistence_config.json";
};
// Test: autotune -> save config -> set override env -> build() -> execute() -> verify success
TEST_F(IntegrationAutotunePersistence, ConfigFileRoundTrip)
{
// Phase 1: Autotune and write config file
{
ConvGraphBundle bundle;
createBuiltConvGraph("autotune_persistence_test_conv", bundle);
auto result = bundle.graph->add_all_engines();
ASSERT_EQ(result.code, ErrorCode::OK) << result.err_msg;
int64_t maxWs = 0;
result = bundle.graph->get_estimated_max_workspace_size(maxWs);
ASSERT_EQ(result.code, ErrorCode::OK) << result.err_msg;
const Workspace workspace(static_cast<size_t>(maxWs));
AutotuneConfig config;
config.mode = TuneMode::STANDARD;
config.strategy = AutotuneStrategy::FIXED_AVERAGE;
config.timedIterations = 1;
config.warmupIterations = 1;
const AutotuneStorageConfig storageConfig{_configFile, false};
std::vector<AutotuneResult> results;
result = bundle.graph->autotune(
_handle, bundle.variantPack, workspace.get(), maxWs, config, storageConfig, &results);
ASSERT_EQ(result.code, ErrorCode::OK) << result.err_msg;
ASSERT_TRUE(std::filesystem::exists(_configFile))
<< "Config file was not created at '" << _configFile << "'";
ASSERT_FALSE(results.empty());
ASSERT_TRUE(results[0].succeeded) << "Winning engine did not succeed";
}
// Phase 2: Build a new graph using the override config file
{
hipdnn_data_sdk::utilities::setEnv("HIPDNN_HEUR_CONFIG_PATH", _configFile.string().c_str());
auto bundle = createConvGraph("autotune_persistence_test_conv");
auto result = bundle.graph->validate();
ASSERT_EQ(result.code, ErrorCode::OK) << result.err_msg;
result = bundle.graph->build(_handle);
ASSERT_EQ(result.code, ErrorCode::OK) << result.err_msg;
bundle.buildVariantPack();
buildWorkspaceAndExecute(bundle);
hipdnn_data_sdk::utilities::unsetEnv("HIPDNN_HEUR_CONFIG_PATH");
}
}
} // namespace