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

174 lines
4.9 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
/**
* @file GraphAttributes.hpp
* @brief Graph-level configuration attributes for hipDNN computational graphs
*
* This file defines the GraphAttributes class which holds configuration settings
* that apply to an entire computational graph, such as default data types.
*/
#pragma once
#include <hipdnn_frontend/Types.hpp>
#include <memory>
#include <string>
#include <unordered_map>
namespace hipdnn_frontend::graph
{
/**
* @class GraphAttributes
* @brief Configuration settings that apply to an entire computational graph
*
* GraphAttributes holds default settings for a graph, including:
* - **compute_data_type**: The data type used for computations (e.g., FLOAT for accumulation)
* - **intermediate_data_type**: The data type for intermediate/virtual tensors
* - **io_data_type**: The data type for input/output tensors
*
* These settings are inherited by tensors and operations that don't explicitly
* specify their own data types.
*
* @code{.cpp}
* Graph graph;
* graph.set_io_data_type(DataType::HALF)
* .set_compute_data_type(DataType::FLOAT)
* .set_intermediate_data_type(DataType::HALF)
* .set_name("my_graph");
* @endcode
*/
class GraphAttributes
{
public:
/**
* @brief Get the name of the graph
* @return The graph name
*/
// NOLINTNEXTLINE(readability-identifier-naming)
const std::string& get_name() const
{
return _name;
}
/**
* @brief Get the compute data type
* @return The data type used for computations/accumulation
*/
// NOLINTNEXTLINE(readability-identifier-naming)
DataType get_compute_data_type() const
{
return _computeType;
}
/**
* @brief Get the intermediate data type
* @return The data type for virtual/intermediate tensors
*/
// NOLINTNEXTLINE(readability-identifier-naming)
DataType get_intermediate_data_type() const
{
return _intermediateType;
}
/**
* @brief Get the I/O data type
* @return The data type for input/output tensors
*/
// NOLINTNEXTLINE(readability-identifier-naming)
DataType get_io_data_type() const
{
return _ioType;
}
/**
* @brief Set the compute data type
* @param computeType The data type for computations/accumulation
* @return Reference to this for method chaining
*/
// NOLINTNEXTLINE(readability-identifier-naming)
GraphAttributes& set_compute_data_type(DataType computeType)
{
_computeType = computeType;
return *this;
}
/**
* @brief Set the intermediate data type
* @param intermediateType The data type for virtual/intermediate tensors
* @return Reference to this for method chaining
*/
// NOLINTNEXTLINE(readability-identifier-naming)
GraphAttributes& set_intermediate_data_type(DataType intermediateType)
{
_intermediateType = intermediateType;
return *this;
}
/**
* @brief Set the I/O data type
* @param ioType The data type for input/output tensors
* @return Reference to this for method chaining
*/
// NOLINTNEXTLINE(readability-identifier-naming)
GraphAttributes& set_io_data_type(DataType ioType)
{
_ioType = ioType;
return *this;
}
/**
* @brief Set the name of the graph
* @param name The graph name (for debugging and logging)
* @return Reference to this for method chaining
*/
// NOLINTNEXTLINE(readability-identifier-naming)
GraphAttributes& set_name(const std::string& name)
{
_name = name;
return *this;
}
/**
* @brief Fill unset properties from another GraphAttributes object
* @param other The source to copy missing properties from
* @return Reference to this for method chaining
*
* Only properties that are NOT_SET or empty will be copied from other.
*/
// NOLINTNEXTLINE(readability-identifier-naming)
GraphAttributes& fill_missing_properties(const GraphAttributes& other)
{
if(_computeType == DataType::NOT_SET)
{
_computeType = other._computeType;
}
if(_intermediateType == DataType::NOT_SET)
{
_intermediateType = other._intermediateType;
}
if(_ioType == DataType::NOT_SET)
{
_ioType = other._ioType;
}
if(_name.empty())
{
_name = other._name;
}
return *this;
}
private:
std::string _name; ///< Graph name for debugging
DataType _computeType = DataType::NOT_SET; ///< Compute/accumulation data type
DataType _intermediateType = DataType::NOT_SET; ///< Intermediate tensor data type
DataType _ioType = DataType::NOT_SET; ///< Input/output tensor data type
};
typedef GraphAttributes Context; ///< @brief Type alias for GraphAttributes
} // namespace hipdnn_frontend::graph