Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/hipdnn-superbuild-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
-DROCM_LIBS_ENABLE_ROOT_CTEST=ON \
-DENABLE_CLANG_FORMAT=OFF \
-DHIPKERNELPROVIDER_ENABLE_ROCKE=ON \
-DHIPDNN_ENABLE_CUDNN_COMPATIBILITY=ON \
-DENABLE_CLANG_TIDY=OFF

- name: Build
Expand Down Expand Up @@ -280,6 +281,7 @@ jobs:
-DENABLE_CLANG_FORMAT=OFF \
-DENABLE_CLANG_TIDY=ON \
-DHIPKERNELPROVIDER_ENABLE_ROCKE=ON \
-DHIPDNN_ENABLE_CUDNN_COMPATIBILITY=ON \
-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-20

- name: Build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@

#pragma once

#include <hipdnn_frontend/attributes/BatchnormAttributes.hpp>
#include <hipdnn_frontend/attributes/BatchnormBackwardAttributes.hpp>
#include <hipdnn_frontend/attributes/BatchnormInferenceAttributes.hpp>
#include <hipdnn_frontend/attributes/BlockScaleDequantizeAttributes.hpp>
#include <hipdnn_frontend/attributes/BlockScaleQuantizeAttributes.hpp>
#include <hipdnn_frontend/attributes/ConvolutionDgradAttributes.hpp>
#include <hipdnn_frontend/attributes/ConvolutionFpropAttributes.hpp>
#include <hipdnn_frontend/attributes/ConvolutionWgradAttributes.hpp>
#include <hipdnn_frontend/attributes/LayernormAttributes.hpp>
#include <hipdnn_frontend/attributes/LayernormBackwardAttributes.hpp>
#include <hipdnn_frontend/attributes/MatmulAttributes.hpp>
#include <hipdnn_frontend/attributes/PointwiseAttributes.hpp>
#include <hipdnn_frontend/attributes/RMSNormAttributes.hpp>
#include <hipdnn_frontend/attributes/RMSNormBackwardAttributes.hpp>
#include <hipdnn_frontend/attributes/ReductionAttributes.hpp>
#include <hipdnn_frontend/attributes/ResampleFwdAttributes.hpp>
#include <hipdnn_frontend/attributes/TensorAttributes.hpp>

namespace hipdnn_frontend::compatibility::cudnn_frontend::graph
Expand All @@ -30,4 +46,25 @@ using hipdnn_frontend::graph::Tensor_attributes;
using hipdnn_frontend::graph::TensorAttributes;
using nv_bfloat16 = hipdnn_frontend::bfloat16;

// Tier-1 node attribute types: each cuDNN v9
// *_attributes class with an exact hipDNN counterpart is aliased 1:1 — zero
// overhead, no wrapper. The matching Graph::* node method forwards straight to
// the wrapped hipDNN graph (see detail/graph_wrapper.h).
using hipdnn_frontend::graph::Batchnorm_attributes;
using hipdnn_frontend::graph::Batchnorm_backward_attributes;
using hipdnn_frontend::graph::Batchnorm_inference_attributes;
using hipdnn_frontend::graph::Block_scale_dequantize_attributes;
using hipdnn_frontend::graph::Block_scale_quantize_attributes;
using hipdnn_frontend::graph::Conv_dgrad_attributes;
using hipdnn_frontend::graph::Conv_fprop_attributes;
using hipdnn_frontend::graph::Conv_wgrad_attributes;
using hipdnn_frontend::graph::Layernorm_attributes;
using hipdnn_frontend::graph::Layernorm_backward_attributes;
using hipdnn_frontend::graph::Matmul_attributes;
using hipdnn_frontend::graph::Pointwise_attributes;
using hipdnn_frontend::graph::Reduction_attributes;
using hipdnn_frontend::graph::Resample_attributes;
using hipdnn_frontend::graph::Rmsnorm_attributes;
using hipdnn_frontend::graph::Rmsnorm_backward_attributes;

} // namespace hipdnn_frontend::compatibility::cudnn_frontend::graph
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* hipDNN's version and from the cuDNN *runtime* version in
* `cudnn_runtime_version.h`. Consumers gate on `CUDNN_FRONTEND_VERSION` (e.g.
* PyTorch's `MHA.cpp`), so it must match upstream. Pinned to cuDNN FE v1.24.0.
*
* This pin is also the single source of truth for the shim's node signatures:
* `detail/graph_wrapper.h` static_asserts on `CUDNN_FRONTEND_VERSION` so a bump
* here cannot land without re-diffing every node arity against upstream.
*/

#pragma once
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
//
// Portions derived from NVIDIA cuDNN frontend
// (include/cudnn_frontend/graph_properties.h and graph_interface.h), used under
// the MIT license.

/**
* @file unsupported_nodes.h
* @brief Tier-2 fail-stub node surface for the hipDNN cuDNN-compatibility shim.
*
* cuDNN v9 defines 39 `*_attributes` node classes; roughly half have a 1:1
* hipDNN equivalent (aliased in `cudnn_frontend/graph_properties.h`). The rest
* have no hipDNN engine yet. So that any hipified v9 source still compiles and
* fails *loudly* (never silently) on those nodes, this header declares each
* missing attribute class and the macros the graph wrapper uses to stamp out a
* matching `Graph::*` node method that records
* `error_code_t::GRAPH_NOT_SUPPORTED`.
*
* The error is recorded on the composition Graph and surfaces from the next
* `validate()` / `build_operation_graph()` — node-adding methods return tensors,
* not `error_t`, so they cannot report it directly.
*
* @note Internal-to-shim; pulled in by `detail/graph_wrapper.h`.
*/

#pragma once

#include <memory>
#include <string>
#include <type_traits>

#include <hipdnn_compatibility/cudnn/cudnn_frontend/graph_helpers.h>
#include <hipdnn_compatibility/cudnn/cudnn_frontend_utils.h>

namespace hipdnn_frontend::compatibility::cudnn_frontend::graph
{
// NOLINTBEGIN(readability-identifier-naming): these classes mirror cuDNN's
// snake_case public spelling for source compatibility.

namespace detail
{

// Common base for a Tier-2 fail-stub attribute class. It carries only the
// universal accessors every cuDNN attribute type shares (`set_name`/`get_name`,
// `set_compute_data_type`/`get_compute_data_type`) so hipified source that
// chains or reads them still compiles, matching the hipDNN attribute types the
// Tier-1 aliases resolve to.
// Node-specific setters are intentionally omitted until a consumer asks for the
// node (consumer-driven landing order); adding one is how the node
// graduates from a stub to a real wrapper/alias.
template <typename Derived>
class UnsupportedAttributes
{
public:
Derived& set_name(const std::string& name)
{
_name = name;
return self();
}

const std::string& get_name() const
{
return _name;
}

Derived& set_compute_data_type(DataType_t type)
{
_computeDataType = type;
return self();
}

DataType_t get_compute_data_type() const
{
return _computeDataType;
}

private:
friend Derived;

UnsupportedAttributes() = default;
Derived& self()
{
return static_cast<Derived&>(*this);
}

std::string _name;
DataType_t _computeDataType = DataType_t::NOT_SET;
};

// A Tier-2 fail-stub records GRAPH_NOT_SUPPORTED but must still hand back a live,
// graph-registered tensor: idiomatic cuDNN FE chains the result
// (`node(...)->set_output(true).set_uid(n)`), so a null return dereferences null
// before the error can surface at validate(). These helpers mint placeholder
// tensor(s) through the graph's public tensor() so they are tracked like any
// other tensor; they are never validated because the recorded error
// short-circuits validate()/build_operation_graph() first. Templated on the graph
// type to avoid a dependency cycle with the wrapper that includes this header.
template <typename Ptr>
struct is_shared_ptr : std::false_type
{
};

template <typename T>
struct is_shared_ptr<std::shared_ptr<T>> : std::true_type
{
};

// Build a fail-stub's return value: a single placeholder tensor, or an array of
// them for multi-output nodes. Result is the node method's declared return type
// (a std::shared_ptr<Tensor_attributes> or a std::array<..., N> of them).
template <typename Result, typename GraphT>
Result makeUnsupportedNodeResult(GraphT& graph)
{
if constexpr(is_shared_ptr<Result>::value)
{
return graph.tensor(typename Result::element_type{});
}
else
{
Result result{};
for(auto& element : result)
{
element = graph.tensor(typename Result::value_type::element_type{});
}
return result;
}
}

} // namespace detail

// Stamp a Tier-2 fail-stub attribute class from an upstream cuDNN v9 class name.
// The user-provided constructor keeps C++17 brace-init from aggregate-initializing
// the private CRTP base constructor directly.
// NOLINTBEGIN(bugprone-macro-parentheses): name is a type token, not an expression.
#define HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(name) \
class name : public detail::UnsupportedAttributes<name> \
{ \
public: \
name() {} /* NOLINT(modernize-use-equals-default) */ \
}
// NOLINTEND(bugprone-macro-parentheses)

/// @brief Unsupported node attribute.
/// hipDNN has no equivalent engine; the node compiles but reports
/// `error_code_t::GRAPH_NOT_SUPPORTED` at validate()/build().
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(BN_finalize_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Genstats_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(DBN_weight_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Matmul_fp8_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Instancenorm_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Instancenorm_backward_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(AdaLayernorm_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(AdaLayernorm_backward_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Rng_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Reshape_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Transpose_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(RoPE_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(RoPE_backward_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(SDPA_fp8_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(SDPA_fp8_backward_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Softmax_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(DiagonalBandMask_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Slice_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(PagedCacheLoad_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Concatenate_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Moe_grouped_matmul_attributes);
/// @copydoc BN_finalize_attributes
HIPDNN_CUDNN_SHIM_FAIL_STUB_ATTRIBUTES(Moe_grouped_matmul_bwd_attributes);

// NOLINTEND(readability-identifier-naming)

} // namespace hipdnn_frontend::compatibility::cudnn_frontend::graph

// Stamp a Tier-2 fail-stub node method body. Records GRAPH_NOT_SUPPORTED on the
// composition Graph — surfaced at the next validate()/build_operation_graph() —
// with a message pointing at the issue tracker, then returns a live,
// graph-registered placeholder result (a real Tensor_attributes, or an array of
// them for multi-output nodes) so idiomatic cuDNN FE chaining
// (`node(...)->set_output(true).set_uid(n)`) survives instead of dereferencing
// null before the recorded error can surface.
//
// Expands inside the shim graph wrapper (detail/graph_wrapper.h), so it relies on
// that class providing recordError(); the placeholder result is built by
// detail::makeUnsupportedNodeResult<Result>(graph) above.
//
// `name` — the cuDNN v9 method name (stringized into the message)
// `params` — the parameter list, PARENTHESIZED so its commas are one macro arg
// `...` — the return type (variadic so its commas, e.g. std::array<T, N>,
// do not split it across arguments)
#define HIPDNN_CUDNN_SHIM_FAIL_NODE(name, params, ...) \
__VA_ARGS__ name params \
{ \
recordError(error_code_t::GRAPH_NOT_SUPPORTED, \
"cuDNN-shim node '" #name "' has no hipDNN equivalent yet; file a " \
"request at https://github.com/ROCm/rocm-libraries/issues"); \
return detail::makeUnsupportedNodeResult<__VA_ARGS__>(*this); \
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,7 @@ class LayernormBackwardAttributes : public Attributes<LayernormBackwardAttribute
return set_mean(std::move(mean)).set_inv_variance(std::move(invVariance));
}
};

typedef LayernormBackwardAttributes
Layernorm_backward_attributes; // NOLINT(readability-identifier-naming)
} // namespace hipdnn_frontend::graph
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,8 @@ class ResampleFwdAttributes : public Attributes<ResampleFwdAttributes>

typedef ResampleFwdAttributes Resample_fwd_attributes; // NOLINT(readability-identifier-naming)

// cuDNN frontend spells the (forward-only, in hipDNN) resample node
// `Resample_attributes`; provide that spelling for API compatibility.
typedef ResampleFwdAttributes Resample_attributes; // NOLINT(readability-identifier-naming)

} // namespace hipdnn_frontend::graph
1 change: 1 addition & 0 deletions projects/hipdnn/frontend/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_executable(
$<$<BOOL:${HIPDNN_ENABLE_CUDNN_COMPATIBILITY}>:TestCudnnShimTensor.cpp>
$<$<BOOL:${HIPDNN_ENABLE_CUDNN_COMPATIBILITY}>:TestCudnnShimV9Tu.cpp>
$<$<BOOL:${HIPDNN_ENABLE_CUDNN_COMPATIBILITY}>:TestCudnnShimGraph.cpp>
$<$<BOOL:${HIPDNN_ENABLE_CUDNN_COMPATIBILITY}>:TestCudnnShimGraphNodes.cpp>
# SDPA node coverage additionally needs the SDPA build.
$<$<AND:$<BOOL:${HIPDNN_ENABLE_CUDNN_COMPATIBILITY}>,$<BOOL:${HIPDNN_ENABLE_SDPA}>>:TestCudnnShimGraphSDPA.cpp>
TestDescriptorHelpers.cpp
Expand Down
Loading
Loading