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
145 lines
6.9 KiB
C++
145 lines
6.9 KiB
C++
/*******************************************************************************
|
|
*
|
|
* MIT License
|
|
*
|
|
* Copyright (C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
*
|
|
* 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.
|
|
*
|
|
*******************************************************************************/
|
|
|
|
#pragma once
|
|
#include <Tensile/MasterSolutionLibrary.hpp>
|
|
#include <Tensile/SingleSolutionLibrary.hpp>
|
|
|
|
#include <Tensile/PredictionLibrary.hpp>
|
|
|
|
#include <Tensile/Debug.hpp>
|
|
#include <tensilelitehost/export.h>
|
|
#include <iostream>
|
|
|
|
namespace TensileLite
|
|
{
|
|
namespace Serialization
|
|
{
|
|
|
|
template <typename MyProblem, typename MySolution, typename IO>
|
|
struct MappingTraits<ProblemPredictionLibrary<MyProblem, MySolution>, IO>
|
|
{
|
|
using Library = ProblemPredictionLibrary<MyProblem, MySolution>;
|
|
using iot = IOTraits<IO>;
|
|
|
|
static void mapping(IO& io, Library& lib)
|
|
{
|
|
auto ctx = static_cast<LibraryIOContext<MySolution>*>(iot::getContext(io));
|
|
if(ctx == nullptr)
|
|
{
|
|
iot::setError(io,
|
|
"ProblemPredictionLibrary requires that context be "
|
|
"set to a SolutionMap.");
|
|
}
|
|
std::vector<int> mappingIndices;
|
|
if(iot::outputting(io))
|
|
{
|
|
mappingIndices.reserve(lib.solution_list.size());
|
|
|
|
for(auto const& pair : lib.solution_list)
|
|
mappingIndices.push_back(pair.first);
|
|
|
|
iot::mapRequired(io, "table", mappingIndices);
|
|
}
|
|
else
|
|
{
|
|
iot::mapRequired(io, "table", mappingIndices);
|
|
if(mappingIndices.empty())
|
|
iot::setError(io,
|
|
"ProblemPredictionLibrary requires non empty "
|
|
"mapping index set.");
|
|
|
|
for(std::size_t local_index = 0; local_index < mappingIndices.size(); local_index++)
|
|
{
|
|
int index = mappingIndices[local_index];
|
|
auto slnIter = ctx->solutions->find(index);
|
|
if(slnIter == ctx->solutions->end())
|
|
{
|
|
iot::setError(
|
|
io,
|
|
concatenate("[ProblemPredictionLibrary] Invalid solution index: ",
|
|
index));
|
|
}
|
|
else
|
|
{
|
|
auto solution = slnIter->second;
|
|
lib.solution_list.emplace_back(index, solution);
|
|
|
|
origami::dim3_t origami_mi;
|
|
if(solution->sizeMapping.matrixInstruction[0] == 0
|
|
&& solution->sizeMapping.matrixInstruction[1] == 0
|
|
&& solution->sizeMapping.matrixInstruction[2] == 0)
|
|
{
|
|
// Override dot2 instruction with vector lane widths
|
|
origami_mi = {1, 1, 64};
|
|
}
|
|
else
|
|
{
|
|
origami_mi = {
|
|
static_cast<size_t>(solution->sizeMapping.matrixInstruction[0]),
|
|
static_cast<size_t>(solution->sizeMapping.matrixInstruction[1]),
|
|
static_cast<size_t>(
|
|
solution->sizeMapping.matrixInstruction[2])};
|
|
}
|
|
|
|
if(Debug::Instance().printPropertyEvaluation()
|
|
&& solution->sizeMapping.CUOccupancy <= 0)
|
|
{
|
|
std::cerr << "TensileLite::DEBUG: sizeMapping.CUOccupancy="
|
|
<< solution->sizeMapping.CUOccupancy
|
|
<< " (<=0) for solution '" << solution->kernelName
|
|
<< "'; clamping to 1 in origami config.\n";
|
|
}
|
|
origami::config_t origami_config = {
|
|
.mt = {solution->sizeMapping.macroTile.x,
|
|
solution->sizeMapping.macroTile.y,
|
|
solution->sizeMapping.depthU},
|
|
.mi = origami_mi,
|
|
.hand_optimized_main_loop
|
|
= (solution->sizeMapping.customMainLoopScheduling > 0) ? true
|
|
: false,
|
|
.subtile = solution->sizeMapping.useSubtileImpl,
|
|
.occupancy
|
|
= std::max(solution->sizeMapping.CUOccupancy, static_cast<int>(1)),
|
|
.workgroup_mapping = solution->sizeMapping.workGroupMapping,
|
|
.cache_hints_a = solution->sizeMapping.nonTemporalA,
|
|
.cache_hints_b = solution->sizeMapping.nonTemporalB,
|
|
.workspace_size = std::numeric_limits<size_t>::max(),
|
|
.workspace_size_per_elem_c = std::numeric_limits<size_t>::max(),
|
|
.index = local_index,
|
|
};
|
|
|
|
lib.origami_config_list.emplace_back(origami_config);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const static bool flow = false;
|
|
};
|
|
} // namespace Serialization
|
|
} // namespace TensileLite
|
|
|