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
110 lines
4.0 KiB
C++
110 lines
4.0 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <rocm_ck/gemm_spec.hpp>
|
|
#include <rocm_ck/validate.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
using ::rocm_ck::AddOp;
|
|
using ::rocm_ck::Args;
|
|
using ::rocm_ck::DataType;
|
|
using ::rocm_ck::GemmAlgorithm;
|
|
using ::rocm_ck::GemmOp;
|
|
using ::rocm_ck::GemmSpec;
|
|
using ::rocm_ck::makeShape;
|
|
using ::rocm_ck::makeSpec;
|
|
using ::rocm_ck::makeStrides;
|
|
using ::rocm_ck::Signature;
|
|
using ::rocm_ck::TargetSet;
|
|
using ::rocm_ck::validate;
|
|
|
|
// A minimal GemmSpec for testing: 3 physical tensors (A, B, C).
|
|
static constexpr auto test_spec = makeSpec(
|
|
Signature{.dtype = DataType::FP16, .ops = {GemmOp{.lhs = "A", .rhs = "B", .out = "C"}}},
|
|
GemmAlgorithm{
|
|
.block_tile = {128, 128, 32}, .block_waves = {2, 2, 1}, .wave_tile = {16, 16, 16}},
|
|
TargetSet::cdna());
|
|
|
|
// A GemmSpec with a D0 tensor (4 physical tensors: A, B, D, C).
|
|
static constexpr auto test_spec_d0 =
|
|
makeSpec(Signature{.dtype = DataType::FP16,
|
|
.ops = {GemmOp{.lhs = "A", .rhs = "B", .out = "C"},
|
|
AddOp{.lhs = "C", .rhs = "bias", .out = "D"}}},
|
|
GemmAlgorithm{
|
|
.block_tile = {128, 128, 32}, .block_waves = {2, 2, 1}, .wave_tile = {16, 16, 16}},
|
|
TargetSet::cdna());
|
|
|
|
// ============================================================================
|
|
// validate() -- passes when all tensors are filled
|
|
// ============================================================================
|
|
|
|
TEST(Validate, PassesWhenAllTensorsFilled)
|
|
{
|
|
int dummy_a = 1, dummy_b = 2, dummy_c = 3;
|
|
|
|
Args args{};
|
|
args.tensors[test_spec.lhs().args_slot] = {&dummy_a, makeShape(64, 32), makeStrides(32, 1)};
|
|
args.tensors[test_spec.rhs().args_slot] = {&dummy_b, makeShape(32, 64), makeStrides(1, 32)};
|
|
args.tensors[test_spec.output().args_slot] = {&dummy_c, makeShape(64, 64), makeStrides(64, 1)};
|
|
|
|
// Should not abort
|
|
validate(args, test_spec);
|
|
}
|
|
|
|
TEST(Validate, PassesWithD0TensorFilled)
|
|
{
|
|
int dummy_a = 1, dummy_b = 2, dummy_c = 3, dummy_bias = 4;
|
|
|
|
Args args{};
|
|
args.tensors[test_spec_d0.lhs().args_slot] = {&dummy_a, makeShape(64, 32), makeStrides(32, 1)};
|
|
args.tensors[test_spec_d0.rhs().args_slot] = {&dummy_b, makeShape(32, 64), makeStrides(1, 32)};
|
|
args.tensors[test_spec_d0.output().args_slot] = {
|
|
&dummy_c, makeShape(64, 64), makeStrides(64, 1)};
|
|
args.tensors[test_spec_d0.d0().args_slot] = {
|
|
&dummy_bias, makeShape(64, 64), makeStrides(64, 1)};
|
|
|
|
// Should not abort
|
|
validate(args, test_spec_d0);
|
|
}
|
|
|
|
// ============================================================================
|
|
// validate() -- aborts when a tensor is missing
|
|
// ============================================================================
|
|
|
|
#ifndef NDEBUG
|
|
TEST(ValidateDeathTest, AbortsOnNullTensorPointer)
|
|
{
|
|
int dummy_a = 1, dummy_b = 2;
|
|
|
|
Args args{};
|
|
args.tensors[test_spec.lhs().args_slot] = {&dummy_a, makeShape(64, 32), makeStrides(32, 1)};
|
|
args.tensors[test_spec.rhs().args_slot] = {&dummy_b, makeShape(32, 64), makeStrides(1, 32)};
|
|
// output slot intentionally left null
|
|
|
|
EXPECT_DEATH(validate(args, test_spec), "tensor \"C\" \\(slot 2\\) has null pointer");
|
|
}
|
|
|
|
TEST(ValidateDeathTest, AbortsOnMissingD0Tensor)
|
|
{
|
|
int dummy_a = 1, dummy_b = 2, dummy_c = 3;
|
|
|
|
Args args{};
|
|
args.tensors[test_spec_d0.lhs().args_slot] = {&dummy_a, makeShape(64, 32), makeStrides(32, 1)};
|
|
args.tensors[test_spec_d0.rhs().args_slot] = {&dummy_b, makeShape(32, 64), makeStrides(1, 32)};
|
|
args.tensors[test_spec_d0.output().args_slot] = {
|
|
&dummy_c, makeShape(64, 64), makeStrides(64, 1)};
|
|
// D0 (bias) slot intentionally left null
|
|
|
|
EXPECT_DEATH(validate(args, test_spec_d0), "tensor \"bias\" \\(slot 3\\) has null pointer");
|
|
}
|
|
|
|
TEST(ValidateDeathTest, ReportsFirstMissingTensor)
|
|
{
|
|
// All slots null -- should report the first one (lhs = "A", slot 0)
|
|
Args args{};
|
|
|
|
EXPECT_DEATH(validate(args, test_spec), "tensor \"A\" \\(slot 0\\) has null pointer");
|
|
}
|
|
#endif
|