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
103 lines
3.1 KiB
C++
103 lines
3.1 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/LiftingTestHelpers.hpp>
|
|
#include <hipdnn_test_sdk/utilities/LoweringTestHelpers.hpp>
|
|
|
|
using namespace hipdnn_frontend;
|
|
using hipdnn_tests::buildConvFpropGraph;
|
|
|
|
namespace
|
|
{
|
|
|
|
// ============================================================================
|
|
// buildConvFpropGraph tests
|
|
// ============================================================================
|
|
|
|
TEST(TestBuildConvFpropGraph, ReturnsNonNullGraph)
|
|
{
|
|
auto graph = buildConvFpropGraph();
|
|
ASSERT_NE(graph, nullptr);
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, DefaultGraphName)
|
|
{
|
|
auto graph = buildConvFpropGraph();
|
|
EXPECT_EQ(graph->get_name(), "ConvFpropTestGraph");
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, CustomGraphName)
|
|
{
|
|
auto graph = buildConvFpropGraph("MyCustomGraph");
|
|
EXPECT_EQ(graph->get_name(), "MyCustomGraph");
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, DefaultDataTypes)
|
|
{
|
|
auto graph = buildConvFpropGraph();
|
|
EXPECT_EQ(graph->get_compute_data_type(), DataType::FLOAT);
|
|
EXPECT_EQ(graph->get_intermediate_data_type(), DataType::FLOAT);
|
|
EXPECT_EQ(graph->get_io_data_type(), DataType::FLOAT);
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, CustomDataTypes)
|
|
{
|
|
auto graph = buildConvFpropGraph("Test", DataType::HALF, DataType::BFLOAT16, DataType::FLOAT);
|
|
EXPECT_EQ(graph->get_compute_data_type(), DataType::HALF);
|
|
EXPECT_EQ(graph->get_intermediate_data_type(), DataType::BFLOAT16);
|
|
EXPECT_EQ(graph->get_io_data_type(), DataType::FLOAT);
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, GraphValidates)
|
|
{
|
|
auto graph = buildConvFpropGraph();
|
|
auto result = graph->validate();
|
|
EXPECT_EQ(result.code, ErrorCode::OK) << result.err_msg;
|
|
}
|
|
|
|
TEST(TestBuildConvFpropGraph, GraphHasOneNode)
|
|
{
|
|
auto graph = buildConvFpropGraph();
|
|
auto result = graph->validate();
|
|
ASSERT_EQ(result.code, ErrorCode::OK);
|
|
|
|
const auto& nodes = graph->getSubNodes();
|
|
EXPECT_EQ(nodes.size(), 1u);
|
|
}
|
|
|
|
// ============================================================================
|
|
// buildTensorMap tests
|
|
// ============================================================================
|
|
|
|
TEST(TestBuildTensorMap, EmptyGraph)
|
|
{
|
|
const hipdnn_flatbuffers_sdk::data_objects::GraphT graphT;
|
|
auto tensorMap = hipdnn_tests::buildTensorMap(graphT);
|
|
EXPECT_TRUE(tensorMap.empty());
|
|
}
|
|
|
|
TEST(TestBuildTensorMap, MapsUidsToTensors)
|
|
{
|
|
hipdnn_flatbuffers_sdk::data_objects::GraphT graphT;
|
|
|
|
auto t1 = std::make_unique<hipdnn_flatbuffers_sdk::data_objects::TensorAttributesT>();
|
|
t1->uid = 10;
|
|
auto t2 = std::make_unique<hipdnn_flatbuffers_sdk::data_objects::TensorAttributesT>();
|
|
t2->uid = 20;
|
|
|
|
graphT.tensors.push_back(std::move(t1));
|
|
graphT.tensors.push_back(std::move(t2));
|
|
|
|
auto tensorMap = hipdnn_tests::buildTensorMap(graphT);
|
|
ASSERT_EQ(tensorMap.size(), 2u);
|
|
EXPECT_NE(tensorMap.count(10), 0u);
|
|
EXPECT_NE(tensorMap.count(20), 0u);
|
|
EXPECT_EQ(tensorMap.at(10)->uid, 10);
|
|
EXPECT_EQ(tensorMap.at(20)->uid, 20);
|
|
}
|
|
|
|
} // namespace
|