-
Notifications
You must be signed in to change notification settings - Fork 326
[hipDNN] [ALMIOPEN-2037] [ALMIOPEN-2038] cuDNN shim: enum/error and Tensor_attributes aliasing #8744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[hipDNN] [ALMIOPEN-2037] [ALMIOPEN-2038] cuDNN shim: enum/error and Tensor_attributes aliasing #8744
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
projects/hipdnn/frontend/include/hipdnn_compatibility/cudnn/cudnn_frontend/graph_helpers.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright © Advanced Micro Devices, Inc., or its affiliates. | ||
| // SPDX-License-Identifier: MIT | ||
| // | ||
| // Portions derived from NVIDIA cuDNN frontend (include/cudnn_frontend/graph_helpers.h | ||
| // and include/cudnn_frontend_Logging.h), used under the MIT license. | ||
|
|
||
| /** | ||
| * @file graph_helpers.h | ||
| * @brief Error-type aliases and error/log macros for the hipDNN cuDNN shim. | ||
| * | ||
| * Contains aliases for cuDNN-compatible types from hipDNN, and | ||
| * re-exports the cuDNN frontend error/log macros. | ||
| * | ||
| * @note Internal-to-shim; pulled in by the umbrella `cudnn_frontend.h`. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <hipdnn_frontend/Error.hpp> | ||
| #include <hipdnn_frontend/Logging.hpp> | ||
|
|
||
| namespace hipdnn_frontend::compatibility::cudnn_frontend | ||
| { | ||
|
|
||
| using hipdnn_frontend::error_code_t; | ||
| using hipdnn_frontend::error_object; | ||
| using hipdnn_frontend::error_t; | ||
|
|
||
| } // namespace hipdnn_frontend::compatibility::cudnn_frontend | ||
|
|
||
| // The log macros forward their `<<`-streamed argument straight into hipDNN's | ||
| // frontend INFO logger. HIPDNN_FE_LOG_INFO gates on HIPDNN_LOG_LEVEL (off by | ||
| // default) and accepts a stream expression, so chained `<<` arguments work. | ||
| #ifndef CUDNN_FE_LOG | ||
| #define CUDNN_FE_LOG(X) HIPDNN_FE_LOG_INFO(X) | ||
| #endif | ||
|
|
||
| // The X argument is a stream expression: it must stay un-parenthesized so it | ||
| // chains off the leftmost LogStream operand (parenthesizing it would force a | ||
| // `const char* << ...` evaluation and break compilation). Same NOLINT pattern | ||
| // the SDK uses for its own streaming log macros. | ||
| #ifndef CUDNN_FE_LOG_LABEL | ||
| #define CUDNN_FE_LOG_LABEL(X) \ | ||
| HIPDNN_FE_LOG_INFO("[cudnn_frontend] " << X) // NOLINT(bugprone-macro-parentheses) | ||
| #endif | ||
|
|
||
| #ifndef CUDNN_FE_LOG_LABEL_ENDL | ||
| #define CUDNN_FE_LOG_LABEL_ENDL(X) \ | ||
| HIPDNN_FE_LOG_INFO("[cudnn_frontend] " << X) // NOLINT(bugprone-macro-parentheses) | ||
| #endif | ||
|
|
||
| #ifndef CUDNN_FE_LOG_BANNER | ||
| #define CUDNN_FE_LOG_BANNER(X) \ | ||
| HIPDNN_FE_LOG_INFO("[cudnn_frontend] === " << X << " ===") // NOLINT(bugprone-macro-parentheses) | ||
| #endif | ||
|
|
||
| /// @brief Evaluate an expression returning `error_t`; on `is_bad()`, log and | ||
| /// propagate it. Mirrors cuDNN FE's `CHECK_CUDNN_FRONTEND_ERROR`. | ||
| #ifndef CHECK_CUDNN_FRONTEND_ERROR | ||
| #define CHECK_CUDNN_FRONTEND_ERROR(x) \ | ||
| do \ | ||
| { \ | ||
| if(auto retval = (x); retval.is_bad()) \ | ||
| { \ | ||
| CUDNN_FE_LOG_LABEL_ENDL("ERROR: " << #x << " at " << __FILE__ << ":" << __LINE__); \ | ||
| return retval; \ | ||
| } \ | ||
| } while(0) | ||
| #endif | ||
|
|
||
| /// @brief If `cond`, log and `return {retval, message}`. Mirrors cuDNN FE's | ||
| /// `RETURN_CUDNN_FRONTEND_ERROR_IF`. | ||
| #ifndef RETURN_CUDNN_FRONTEND_ERROR_IF | ||
| #define RETURN_CUDNN_FRONTEND_ERROR_IF(cond, retval, message) \ | ||
| do \ | ||
| { \ | ||
| if(cond) \ | ||
| { \ | ||
| if((retval) == error_code_t::OK) \ | ||
| { \ | ||
| CUDNN_FE_LOG_LABEL("INFO: "); \ | ||
| } \ | ||
| else \ | ||
| { \ | ||
| CUDNN_FE_LOG_LABEL("ERROR: "); \ | ||
| } \ | ||
| CUDNN_FE_LOG((message) << ". because (" << #cond ") at " << __FILE__ << ":" \ | ||
| << __LINE__ << "\n"); \ | ||
| return {retval, message}; \ | ||
| } \ | ||
| } while(0) | ||
| #endif |
31 changes: 31 additions & 0 deletions
31
...ects/hipdnn/frontend/include/hipdnn_compatibility/cudnn/cudnn_frontend/graph_properties.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright © Advanced Micro Devices, Inc., or its affiliates. | ||
| // SPDX-License-Identifier: MIT | ||
| // | ||
| // Portions derived from NVIDIA cuDNN frontend | ||
| // (include/cudnn_frontend/graph_properties.h), used under the MIT license. | ||
|
|
||
| /** | ||
| * @file graph_properties.h | ||
| * @brief Graph attribute-type aliases for the hipDNN cuDNN-compatibility shim. | ||
| * | ||
| * Brings hipDNN's v9 graph attribute types into `<shim_ns>::graph` by aliasing | ||
| * them with `using` declarations — zero overhead, no shim-side state. A tensor | ||
| * configured through the shim therefore *is* a hipDNN `TensorAttributes` and | ||
| * flows into a wrapped hipDNN graph with no conversion (UID handling stays on | ||
| * the hipDNN side). | ||
| * | ||
| * @note Internal-to-shim; pulled in by the umbrella `cudnn_frontend.h`. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <hipdnn_frontend/attributes/TensorAttributes.hpp> | ||
|
|
||
| namespace hipdnn_frontend::compatibility::cudnn_frontend::graph | ||
| { | ||
|
|
||
| // hipDNN publishes cuDNN's `Tensor_attributes` spelling as a typedef; aliasing | ||
| // it lets consumer code using that name resolve through the shim. | ||
| using hipdnn_frontend::graph::Tensor_attributes; | ||
|
|
||
| } // namespace hipdnn_frontend::compatibility::cudnn_frontend::graph |
54 changes: 54 additions & 0 deletions
54
projects/hipdnn/frontend/include/hipdnn_compatibility/cudnn/cudnn_frontend_utils.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright © Advanced Micro Devices, Inc., or its affiliates. | ||
| // SPDX-License-Identifier: MIT | ||
| // | ||
| // Portions derived from NVIDIA cuDNN frontend (include/cudnn_frontend_utils.h), | ||
| // used under the MIT license. | ||
|
|
||
| /** | ||
| * @file cudnn_frontend_utils.h | ||
| * @brief FE-namespace enum aliases for the hipDNN cuDNN-compatibility shim. | ||
| * | ||
| * The v9 graph API signatures use cuDNN's FE-namespace enums (`DataType_t`, | ||
| * `PointwiseMode_t`, …), not the C-API ones from `<cudnn.h>`. hipDNN already | ||
| * publishes these as cuDNN-named `_t` typedefs (see `Types.hpp`), so this header | ||
| * just aliases them into `<shim_ns>` with `using` declarations — zero overhead, | ||
| * no numeric cast between enum families. | ||
| * | ||
| * @note Internal-to-shim; pulled in by the umbrella `cudnn_frontend.h`. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <hipdnn_frontend/Types.hpp> | ||
|
|
||
| namespace hipdnn_frontend::compatibility::cudnn_frontend | ||
| { | ||
|
|
||
| // FE-namespace enums hipDNN publishes 1:1, aliased so e.g. | ||
| // `cudnn_frontend::DataType_t` *is* `hipdnn_frontend::DataType_t`. | ||
| using hipdnn_frontend::AttentionImplementation_t; | ||
| using hipdnn_frontend::BehaviorNote_t; | ||
| using hipdnn_frontend::BuildPlanPolicy_t; | ||
| using hipdnn_frontend::ConvolutionMode_t; | ||
| using hipdnn_frontend::DataType_t; | ||
| using hipdnn_frontend::DiagonalAlignment_t; | ||
| using hipdnn_frontend::HeurMode_t; | ||
| using hipdnn_frontend::NormFwdPhase_t; | ||
| using hipdnn_frontend::PaddingMode_t; | ||
| using hipdnn_frontend::PointwiseMode_t; | ||
| using hipdnn_frontend::ReductionMode_t; | ||
| using hipdnn_frontend::ResampleMode_t; | ||
|
|
||
| // Other cuDNN FE-namespace enums (NumericalNote_t, NormMode_t, RngDistribution_t, | ||
| // DescriptorType_t, MoeGroupedMatmulMode_t, TensorReordering_t, ReshapeMode_t) | ||
| // are not aliased yet: hipDNN does not publish them and their nodes are out of | ||
| // scope. They are aliased when their node lands. | ||
|
|
||
| } // namespace hipdnn_frontend::compatibility::cudnn_frontend | ||
|
|
||
| // The `graph` sub-namespace is populated by the `cudnn_frontend/*` headers the | ||
| // umbrella pulls in; declared empty here so this header is self-contained when | ||
| // included on its own. | ||
| namespace hipdnn_frontend::compatibility::cudnn_frontend::graph | ||
| { | ||
| } // namespace hipdnn_frontend::compatibility::cudnn_frontend::graph |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.