hipDNN frontend error C++ API#

2026-03-31

3 min read time

Applies to Linux and Windows

Error handling types and macros for the hipDNN Frontend API.

This file defines the error handling infrastructure used throughout the hipDNN frontend. It includes error codes, the Error struct for detailed error information, and helper macros for error checking and propagation.

Defines

HIPDNN_CHECK_ERROR(x)#

Check an Error return value and propagate if an error occurred.

This macro evaluates the expression and returns immediately if the result indicates an error (is_bad() returns true).

Parameters:
  • x – Expression returning an Error object

HIPDNN_RETURN_IF_NE(x, y, error_status, message)#
HIPDNN_RETURN_IF_EQ(x, y, error_status, message)#
HIPDNN_RETURN_IF_TRUE(x, error_status, message)#
HIPDNN_RETURN_IF_FALSE(x, error_status, message)#
HIPDNN_RETURN_IF_NULL(x, error_status, message)#
HIPDNN_RETURN_IF_LT(x, y, error_status, message)#
HIPDNN_RETURN_IF_GE(x, y, error_status, message)#
HIPDNN_RETURN_IF_LE(x, y, error_status, message)#
namespace hipdnn_frontend#

Typedefs

typedef ErrorCode error_code_t#

Type alias for ErrorCode.

typedef Error error_object#

Type alias for Error (compatibility)

typedef Error error_t#

Type alias for Error.

Enums

enum class ErrorCode#

Error codes returned by hipDNN Frontend operations.

Values:

enumerator OK#

Operation completed successfully.

enumerator INVALID_VALUE#

An invalid value was provided.

enumerator HIPDNN_BACKEND_ERROR#

An error occurred in the hipDNN backend.

enumerator ATTRIBUTE_NOT_SET#

A required attribute was not set.

Functions

inline std::string to_string(ErrorCode code)#
inline std::ostream &operator<<(std::ostream &os, const ErrorCode &error)#
inline std::ostream &operator<<(std::ostream &os, const Error &error)#
struct Error#
#include <Error.hpp>

Represents an error with a code and descriptive message.

The Error struct is the primary mechanism for reporting errors in hipDNN Frontend operations. It combines an ErrorCode with a human-readable message describing what went wrong.

Error result = graph.build(handle);
if(result.is_bad())
{
    std::cerr << "Build failed: " << result.get_message() << std::endl;
}

Public Functions

inline Error()#

Default constructor, creates a success result.

inline Error(ErrorCode errorCode, std::string message)#

Construct an Error with a specific code and message.

Parameters:
  • errorCode – The error code

  • message – Descriptive message about the error

inline std::string get_message() const#

Get the error message.

Returns:

The error message string

inline ErrorCode get_code() const#

Get the error code.

Returns:

The ErrorCode value

inline bool is_good() const#

Check if the operation succeeded.

Returns:

true if code == ErrorCode::OK, false otherwise

inline bool is_bad() const#

Check if the operation failed.

Returns:

true if code != ErrorCode::OK, false otherwise

inline bool operator==(ErrorCode otherCode) const#

Compare error code with an ErrorCode value.

inline bool operator!=(ErrorCode otherCode) const#

Compare error code with an ErrorCode value (inequality)

inline bool operator==(const Error &other) const#

Compare two Error objects by their error codes.

inline bool operator!=(const Error &other) const#

Compare two Error objects by their error codes (inequality)

Public Members

ErrorCode code#

The error code.

std::string err_msg#

Detailed error message // NOLINT(readability-identifier-naming)