Files
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

89 lines
3.2 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <hipdnn_frontend/attributes/Attributes.hpp>
#include <hipdnn_frontend/attributes/TensorAttributes.hpp>
using namespace hipdnn_frontend;
using namespace hipdnn_frontend::graph;
struct Dummy : Attributes<Dummy>
{
std::unordered_map<int, std::shared_ptr<TensorAttributes>> inputs;
std::unordered_map<int, std::shared_ptr<TensorAttributes>> outputs;
};
TEST(TestAttributes, FillFromContext)
{
GraphAttributes graphAttributes;
graphAttributes.set_compute_data_type(DataType::INT32);
graphAttributes.set_intermediate_data_type(DataType::BFLOAT16);
graphAttributes.set_io_data_type(DataType::HALF);
const int nonVirtualId = 0;
const int virtualId = 1;
const int setTypeId = 2;
Dummy attributes;
attributes.inputs[nonVirtualId] = std::make_shared<TensorAttributes>();
attributes.inputs[virtualId] = std::make_shared<TensorAttributes>();
attributes.inputs[virtualId]->set_is_virtual(true);
attributes.inputs[setTypeId] = std::make_shared<TensorAttributes>();
attributes.inputs[setTypeId]->set_data_type(DataType::FLOAT);
attributes.outputs[nonVirtualId] = std::make_shared<TensorAttributes>();
attributes.outputs[virtualId] = std::make_shared<TensorAttributes>();
attributes.outputs[virtualId]->set_is_virtual(true);
attributes.outputs[setTypeId] = std::make_shared<TensorAttributes>();
attributes.outputs[setTypeId]->set_data_type(DataType::DOUBLE);
EXPECT_EQ(attributes.get_compute_data_type(), DataType::NOT_SET);
attributes.fill_from_context(graphAttributes);
EXPECT_EQ(attributes.get_compute_data_type(), graphAttributes.get_compute_data_type());
EXPECT_EQ(attributes.inputs[nonVirtualId]->get_data_type(), graphAttributes.get_io_data_type());
EXPECT_EQ(attributes.inputs[virtualId]->get_data_type(),
graphAttributes.get_intermediate_data_type());
EXPECT_EQ(attributes.inputs[setTypeId]->get_data_type(), DataType::FLOAT);
EXPECT_EQ(attributes.outputs[nonVirtualId]->get_data_type(),
graphAttributes.get_io_data_type());
EXPECT_EQ(attributes.outputs[virtualId]->get_data_type(),
graphAttributes.get_intermediate_data_type());
EXPECT_EQ(attributes.outputs[setTypeId]->get_data_type(), DataType::DOUBLE);
}
TEST(TestAttributes, FillFromContextSetNodeComputeTypeNotOverriden)
{
GraphAttributes graphAttributes;
graphAttributes.set_compute_data_type(DataType::INT32);
auto nodeDataType = hipdnn_frontend::DataType::INT32;
Dummy attributes;
attributes.set_compute_data_type(nodeDataType);
attributes.fill_from_context(graphAttributes);
EXPECT_EQ(attributes.get_compute_data_type(), nodeDataType);
}
TEST(TestAttributes, FillFromContextSetNodeComputeTypeDoesNotUnset)
{
GraphAttributes graphAttributes;
graphAttributes.set_compute_data_type(DataType::NOT_SET);
auto nodeDataType = hipdnn_frontend::DataType::INT32;
Dummy attributes;
attributes.set_compute_data_type(nodeDataType);
attributes.fill_from_context(graphAttributes);
EXPECT_EQ(attributes.get_compute_data_type(), nodeDataType);
}