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
170 lines
4.7 KiB
C++
170 lines
4.7 KiB
C++
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/**
|
|
* @file CustomOpAttributes.hpp
|
|
* @brief Attributes for custom (plugin-provided) operations
|
|
*
|
|
* This file defines the CustomOpAttributes class used to configure opaque
|
|
* plugin operations. Custom ops carry tensor I/O structure (UIDs for graph
|
|
* topology) and an opaque byte payload that a plugin interprets.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "GraphAttributes.hpp"
|
|
#include "TensorAttributes.hpp"
|
|
#include <hipdnn_frontend/Error.hpp>
|
|
#include <hipdnn_frontend/Types.hpp>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace hipdnn_frontend::graph
|
|
{
|
|
|
|
/**
|
|
* @class CustomOpAttributes
|
|
* @brief Configuration attributes for a custom (plugin-provided) operation
|
|
*
|
|
* Custom ops let users coordinate directly with plugins without requiring
|
|
* hipDNN to understand the operation. hipDNN transports the tensor I/O
|
|
* topology and an opaque byte payload (`data`), and the target plugin
|
|
* interprets the payload at execution time.
|
|
*
|
|
* Unlike other attributes classes, CustomOpAttributes does not inherit from
|
|
* Attributes<> because custom ops use variable-length positional tensor
|
|
* vectors rather than named tensor maps.
|
|
*
|
|
* The `custom_op_id` identifies which plugin handles the operation, using
|
|
* dotted namespace notation: `"<plugin>.<operation>"` (e.g. `"example.rope"`).
|
|
*
|
|
* @see Graph::custom_op()
|
|
* @see CustomOpNode
|
|
*/
|
|
class CustomOpAttributes
|
|
{
|
|
public:
|
|
CustomOpAttributes() = default;
|
|
|
|
// NOLINTBEGIN(readability-identifier-naming)
|
|
std::string name;
|
|
DataType compute_data_type = DataType::NOT_SET;
|
|
/// Unique identifier for the plugin operation, using dotted namespace
|
|
/// notation: "<plugin>.<operation>" (e.g. "example.rope", "mylib.fused_add").
|
|
std::string custom_op_id;
|
|
std::vector<std::shared_ptr<TensorAttributes>> inputs;
|
|
std::vector<std::shared_ptr<TensorAttributes>> outputs;
|
|
std::vector<uint8_t> data;
|
|
// NOLINTEND(readability-identifier-naming)
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_name(const std::string& nameValue)
|
|
{
|
|
name = nameValue;
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
const std::string& get_name() const
|
|
{
|
|
return name;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_compute_data_type(DataType value)
|
|
{
|
|
compute_data_type = value;
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
DataType get_compute_data_type() const
|
|
{
|
|
return compute_data_type;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_custom_op_id(const std::string& value)
|
|
{
|
|
custom_op_id = value;
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
const std::string& get_custom_op_id() const
|
|
{
|
|
return custom_op_id;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_inputs(std::vector<std::shared_ptr<TensorAttributes>> value)
|
|
{
|
|
inputs = std::move(value);
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
const std::vector<std::shared_ptr<TensorAttributes>>& get_inputs() const
|
|
{
|
|
return inputs;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_outputs(std::vector<std::shared_ptr<TensorAttributes>> value)
|
|
{
|
|
outputs = std::move(value);
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
const std::vector<std::shared_ptr<TensorAttributes>>& get_outputs() const
|
|
{
|
|
return outputs;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
CustomOpAttributes& set_data(std::vector<uint8_t> value)
|
|
{
|
|
data = std::move(value);
|
|
return *this;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
const std::vector<uint8_t>& get_data() const
|
|
{
|
|
return data;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
Error fill_from_context(const GraphAttributes& graphAttributes)
|
|
{
|
|
for(auto& tensor : inputs)
|
|
{
|
|
if(tensor)
|
|
{
|
|
tensor->fill_from_context(graphAttributes);
|
|
}
|
|
}
|
|
|
|
for(auto& tensor : outputs)
|
|
{
|
|
if(tensor)
|
|
{
|
|
tensor->fill_from_context(graphAttributes);
|
|
}
|
|
}
|
|
|
|
if(get_compute_data_type() == DataType::NOT_SET)
|
|
{
|
|
set_compute_data_type(graphAttributes.get_compute_data_type());
|
|
}
|
|
|
|
return {};
|
|
}
|
|
};
|
|
|
|
typedef CustomOpAttributes Custom_op_attributes; // NOLINT(readability-identifier-naming)
|
|
|
|
} // namespace hipdnn_frontend::graph
|