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
89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <rocm_ck/layout.hpp>
|
|
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <array>
|
|
|
|
using ::rocm_ck::isValidLayoutForRank;
|
|
using ::rocm_ck::Layout;
|
|
using ::rocm_ck::layoutName;
|
|
using ::rocm_ck::layoutStrides;
|
|
using ::rocm_ck::leadingDimStride;
|
|
using ::testing::ElementsAre;
|
|
|
|
namespace {
|
|
|
|
// ============================================================================
|
|
// layoutName
|
|
// ============================================================================
|
|
|
|
TEST(Layout, MapsEnumValuesToExpectedStrings)
|
|
{
|
|
EXPECT_STREQ(layoutName(Layout::Row), "Row");
|
|
EXPECT_STREQ(layoutName(Layout::Col), "Col");
|
|
EXPECT_STREQ(layoutName(Layout::Auto), "Auto");
|
|
}
|
|
|
|
// ============================================================================
|
|
// isValidLayoutForRank
|
|
// ============================================================================
|
|
|
|
TEST(Layout, AllowsRowAndColOnlyForRank2)
|
|
{
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Row, 1));
|
|
EXPECT_TRUE(isValidLayoutForRank(Layout::Row, 2));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Col, 1));
|
|
EXPECT_TRUE(isValidLayoutForRank(Layout::Col, 2));
|
|
}
|
|
|
|
TEST(Layout, RejectsAutoForAllRanks)
|
|
{
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Auto, 0));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Auto, 1));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Auto, 2));
|
|
}
|
|
|
|
TEST(Layout, RejectsRowAndColForRankGreaterThan2)
|
|
{
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Row, 3));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Row, 4));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Row, 6));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Col, 3));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Col, 4));
|
|
EXPECT_FALSE(isValidLayoutForRank(Layout::Col, 6));
|
|
}
|
|
|
|
// ============================================================================
|
|
// leadingDimStride
|
|
// ============================================================================
|
|
|
|
TEST(Layout, LeadingDimStrideReturnsFirstForRow)
|
|
{
|
|
EXPECT_EQ(leadingDimStride(Layout::Row, std::array{128, 1}), 128);
|
|
}
|
|
|
|
TEST(Layout, LeadingDimStrideReturnsSecondForCol)
|
|
{
|
|
EXPECT_EQ(leadingDimStride(Layout::Col, std::array{1, 64}), 64);
|
|
}
|
|
|
|
// ============================================================================
|
|
// layoutStrides
|
|
// ============================================================================
|
|
|
|
TEST(Layout, LayoutStridesRowMajor)
|
|
{
|
|
EXPECT_THAT(layoutStrides(Layout::Row, 32, 64), ElementsAre(64, 1));
|
|
}
|
|
|
|
TEST(Layout, LayoutStridesColMajor)
|
|
{
|
|
EXPECT_THAT(layoutStrides(Layout::Col, 32, 64), ElementsAre(1, 32));
|
|
}
|
|
|
|
} // namespace
|