hipDNN frontend types C++ API

Contents

hipDNN frontend types C++ API#

2026-03-31

13 min read time

Applies to Linux and Windows

Core type definitions and enumerations for the hipDNN Frontend API.

Defines the fundamental enums that configure hipDNN operations:

hipDNN enum

Concept

Purpose

DataType

Numeric precision

fp32, fp16, bf16, fp8, etc.

PointwiseMode

Activation / element-wise op

relu, gelu, add, mul, etc.

ConvolutionMode

Filter application method

Cross-correlation vs mathematical convolution

NormFwdPhase

Training vs inference

Whether to save stats for backward pass

DiagonalAlignment

SDPA causal mask alignment

Top-left vs bottom-right diagonal

AttentionImplementation

SDPA execution strategy

Auto, composite, or unified kernel

HeuristicMode

Engine discovery mode

How engines are ranked

BuildPlanPolicy

Plan selection policy

Heuristic choice vs build all

KnobValueType

Engine knob data type

int64, float64, or string

This file also contains conversion utilities between frontend types and the internal SDK/backend types.

namespace hipdnn_frontend

Typedefs

typedef ConvolutionMode ConvolutionMode_t#

Type alias for ConvolutionMode.

typedef PointwiseMode PointwiseMode_t#

Type alias for PointwiseMode.

typedef ReductionMode ReductionMode_t#

Type alias for ReductionMode.

typedef DataType DataType_t#

Type alias for DataType.

typedef DiagonalAlignment DiagonalAlignment_t#

Type alias for DiagonalAlignment.

typedef AttentionImplementation AttentionImplementation_t#

Type alias for AttentionImplementation.

typedef HeuristicMode HeurMode_t#

Type alias for HeuristicMode.

typedef BuildPlanPolicy BuildPlanPolicy_t#

Type alias for BuildPlanPolicy.

typedef NormFwdPhase NormFwdPhase_t#

Type alias for NormFwdPhase.

typedef KnobValueType KnobValueType_t#

Type alias for KnobValueType.

Enums

enum class ConvolutionMode#

Specifies the convolution algorithm mode.

Determines how the convolution filter is applied to the input tensor.

Values:

enumerator NOT_SET#

Mode not specified.

enumerator CROSS_CORRELATION#

Cross-correlation mode (standard deep learning convolution)

enumerator CONVOLUTION#

Mathematical convolution (filter is flipped)

enum class PointwiseMode#

Specifies the type of element-wise (pointwise) operation.

Pointwise operations are applied element-by-element to tensors. They can be unary (1 input), binary (2 inputs), or ternary (3 inputs).

Values:

enumerator NOT_SET#

Mode not specified.

enumerator ABS#

Absolute value: |x|.

enumerator ADD#

Addition: x + y.

enumerator ADD_SQUARE#

Add and square: (x + y)²

enumerator BINARY_SELECT#

Ternary select based on condition.

enumerator CEIL#

Ceiling function.

enumerator CMP_EQ#

Compare equal: x == y.

enumerator CMP_GE#

Compare greater or equal: x >= y.

enumerator CMP_GT#

Compare greater than: x > y.

enumerator CMP_LE#

Compare less or equal: x <= y.

enumerator CMP_LT#

Compare less than: x < y.

enumerator CMP_NEQ#

Compare not equal: x != y.

enumerator DIV#

Division: x / y.

enumerator ELU_BWD#

ELU activation backward pass.

enumerator ELU_FWD#

ELU activation forward pass.

enumerator ERF#

Error function.

enumerator EXP#

Exponential: e^x.

enumerator FLOOR#

Floor function.

enumerator GELU_APPROX_TANH_BWD#

GELU (tanh approximation) backward.

enumerator GELU_APPROX_TANH_FWD#

GELU (tanh approximation) forward.

enumerator GELU_BWD#

GELU activation backward.

enumerator GELU_FWD#

GELU activation forward.

enumerator GEN_INDEX#

Generate index tensor.

enumerator IDENTITY#

Identity: y = x.

enumerator LOG#

Natural logarithm.

enumerator LOGICAL_AND#

Logical AND.

enumerator LOGICAL_NOT#

Logical NOT.

enumerator LOGICAL_OR#

Logical OR.

enumerator MAX#

Element-wise maximum.

enumerator MIN#

Element-wise minimum.

enumerator MUL#

Multiplication: x * y.

enumerator NEG#

Negation: -x.

enumerator RECIPROCAL#

Reciprocal: 1/x.

enumerator RELU_BWD#

ReLU backward pass.

enumerator RELU_FWD#

ReLU forward pass.

enumerator RSQRT#

Reciprocal square root: 1/sqrt(x)

enumerator SIGMOID_BWD#

Sigmoid backward pass.

enumerator SIGMOID_FWD#

Sigmoid forward pass.

enumerator SIN#

Sine function.

enumerator SOFTPLUS_BWD#

Softplus backward pass.

enumerator SOFTPLUS_FWD#

Softplus forward pass.

enumerator SQRT#

Square root.

enumerator SUB#

Subtraction: x - y.

enumerator SWISH_BWD#

Swish activation backward.

enumerator SWISH_FWD#

Swish activation forward.

enumerator TAN#

Tangent function.

enumerator TANH_BWD#

Tanh backward pass.

enumerator TANH_FWD#

Tanh forward pass.

enum class ReductionMode#

Specifies the reduction operation to perform.

Matches the cudnn-frontend ReductionMode_t enumeration for API compatibility.

Values:

enumerator NOT_SET#

Reduction mode not specified.

enumerator ADD#

Sum reduction.

enumerator MUL#

Product reduction.

enumerator MIN#

Minimum reduction.

enumerator MAX#

Maximum reduction.

enumerator AMAX#

Absolute maximum reduction.

enumerator AVG#

Average reduction.

enumerator NORM1#

L1 norm reduction.

enumerator NORM2#

L2 norm reduction.

enumerator MUL_NO_ZEROS#

Product reduction excluding zeros.

enum class DataType#

Specifies the data type for tensor elements.

Defines the numeric precision and format for tensor data. Different operations may support different subsets of data types.

Values:

enumerator NOT_SET#

Data type not specified.

enumerator FLOAT#

32-bit floating point (fp32)

enumerator HALF#

16-bit floating point (fp16, IEEE 754)

enumerator BFLOAT16#

16-bit brain floating point (bf16)

enumerator DOUBLE#

64-bit floating point (fp64)

enumerator UINT8#

8-bit unsigned integer

enumerator INT32#

32-bit signed integer

enumerator INT8#

8-bit signed integer

enumerator FP8_E4M3#

8-bit floating point (4 exponent, 3 mantissa bits)

enumerator FP8_E5M2#

8-bit floating point (5 exponent, 2 mantissa bits)

enumerator FP8_E8M0#

8-bit floating point (8 exponent, 0 mantissa bits)

enumerator FP4_E2M1#

4-bit floating point (2 exponent, 1 mantissa bit)

enumerator INT4#

4-bit signed integer

enumerator FP6_E2M3#

6-bit floating point (2 exponent, 3 mantissa bits)

enumerator FP6_E3M2#

6-bit floating point (3 exponent, 2 mantissa bits)

enum class DiagonalAlignment#

Diagonal alignment mode for SDPA causal masking.

Controls which corner of the attention matrix the causal mask diagonal is anchored to. This affects how the triangular mask is positioned when query and key sequence lengths differ (S_q != S_kv).

For equal-length sequences both modes produce the same mask. When S_q < S_kv, BOTTOM_RIGHT aligns the mask so that each query attends to the most recent keys rather than the earliest.

See also

hipdnn_frontend::graph::SdpaAttributes::set_diagonal_alignment()

Values:

enumerator TOP_LEFT#

Anchor mask diagonal to the top-left corner of the attention matrix.

enumerator BOTTOM_RIGHT#

Anchor mask diagonal to the bottom-right corner of the attention matrix.

enum class AttentionImplementation#

Execution strategy for scaled dot-product attention.

Selects how the SDPA computation is mapped to GPU kernels.

See also

hipdnn_frontend::graph::SdpaAttributes::set_implementation()

Values:

enumerator AUTO#

Let the backend choose the best strategy for the given configuration.

enumerator COMPOSITE#

Decompose attention into separate matmul, softmax, and matmul kernels.

enumerator UNIFIED#

Use a single fused kernel for the entire attention computation.

enum class HeuristicMode#

Specifies the heuristic mode for engine selection.

Controls how the hipDNN backend selects execution plans and engines.

Values:

enumerator FALLBACK#

Use fallback heuristics for engine selection.

enum class BuildPlanPolicy#

Specifies how execution plans are selected during graph building.

Values:

enumerator HEURISTICS_CHOICE#

Use heuristics to select the best plan.

enumerator ALL#

Build all available plans (currently unused)

enum class NormFwdPhase#

Specifies the forward phase for normalization operations.

Controls whether the normalization operation computes auxiliary outputs (e.g., inverse variance/RMS) needed for backward pass training.

Values:

enumerator NOT_SET#

Phase not specified (invalid for execution)

enumerator INFERENCE#

Inference mode: only Y output computed.

enumerator TRAINING#

Training mode: Y and inverse RMS/variance outputs computed.

enum class KnobValueType#

Specifies the data type of a knob value.

Knobs are configuration parameters for engine execution. This enum indicates what type of value a particular knob expects.

See also

hipdnn_frontend::Knob

See also

hipdnn_frontend::KnobSetting

Values:

enumerator NOT_SET#

Value type not specified.

enumerator INT64#

64-bit signed integer value

enumerator FLOAT64#

64-bit floating point value

enumerator STRING#

String value.

Functions

template<typename T>
DataType getDataTypeEnumFromType()#

Get the DataType enum value corresponding to a C++ type.

DataType dt = getDataTypeEnumFromType<float>();  // Returns DataType::FLOAT
DataType dt2 = getDataTypeEnumFromType<half>();  // Returns DataType::HALF

Template Parameters:

T – The C++ type (float, half, hip_bfloat16, double, etc.)

Returns:

The corresponding DataType enum value

inline hipdnn_data_sdk::data_objects::ConvMode toSdkType(const ConvolutionMode &type)#

Convert frontend ConvolutionMode to SDK ConvMode.

inline std::optional<hipdnnConvolutionMode_t> toBackendConvMode(const ConvolutionMode &type)#

Convert frontend ConvolutionMode to backend hipdnnConvolutionMode_t.

Maps frontend convolution mode enum to the backend C API enum type for use with HIPDNN_TYPE_CONVOLUTION_MODE attributes.

Parameters:

type – The frontend ConvolutionMode value

Returns:

The corresponding hipdnnConvolutionMode_t value, or std::nullopt if not set

inline std::pair<ConvolutionMode, Error> fromHipdnnConvMode(hipdnnConvolutionMode_t mode)#

Convert backend hipdnnConvolutionMode_t to frontend ConvolutionMode.

Maps the backend C API convolution mode enum to the frontend ConvolutionMode enum.

Parameters:

mode – The backend hipdnnConvolutionMode_t value

Returns:

A pair of the corresponding ConvolutionMode and an Error (set if the mode is unknown)

inline hipdnnDiagonalAlignment_t toBackendDiagonalAlignment(const DiagonalAlignment &type)#

Convert frontend DiagonalAlignment to backend hipdnnDiagonalAlignment_t.

Maps frontend diagonal alignment enum directly to the backend C API enum type for use with HIPDNN_TYPE_DIAGONAL_ALIGNMENT attributes.

Parameters:

type – The frontend DiagonalAlignment value

Returns:

The corresponding hipdnnDiagonalAlignment_t value

inline hipdnnAttentionImplementation_t toBackendAttentionImplementation(const AttentionImplementation &type)#

Convert frontend AttentionImplementation to backend hipdnnAttentionImplementation_t.

Maps frontend attention implementation enum directly to the backend C API enum type for use with HIPDNN_TYPE_ATTENTION_IMPLEMENTATION attributes.

Parameters:

type – The frontend AttentionImplementation value

Returns:

The corresponding hipdnnAttentionImplementation_t value

inline std::optional<hipdnnNormFwdPhase_t> toBackendNormFwdPhase(const NormFwdPhase &type)#

Convert frontend NormFwdPhase to backend hipdnnNormFwdPhase_t.

Maps frontend normalization forward phase to the backend C API enum type for use with HIPDNN_TYPE_NORM_FWD_PHASE attributes.

Parameters:

type – The frontend NormFwdPhase value

Returns:

The corresponding hipdnnNormFwdPhase_t value, or std::nullopt if not set

inline std::pair<NormFwdPhase, Error> fromHipdnnNormFwdPhase(hipdnnNormFwdPhase_t phase)#

Convert backend hipdnnNormFwdPhase_t to frontend NormFwdPhase.

Maps backend C API normalization forward phase enum to the frontend enum type.

Parameters:

phase – The backend hipdnnNormFwdPhase_t value

Returns:

A pair of NormFwdPhase and Error; error is set for unknown values

inline std::optional<hipdnnPointwiseMode_t> toBackendPointwiseMode(const PointwiseMode &type)#

Convert frontend PointwiseMode to backend hipdnnPointwiseMode_t.

Maps frontend pointwise mode enum to the backend C API enum type for use with HIPDNN_TYPE_POINTWISE_MODE attributes.

Parameters:

type – The frontend PointwiseMode value

Returns:

The corresponding hipdnnPointwiseMode_t value, or std::nullopt if not set

inline hipdnn_frontend::ConvolutionMode fromSdkType(const hipdnn_data_sdk::data_objects::ConvMode &type)#

Convert SDK ConvMode to frontend ConvolutionMode.

inline hipdnn_data_sdk::data_objects::DataType toSdkType(const DataType &type)#

Convert frontend DataType to SDK DataType.

inline hipdnn_frontend::DataType fromSdkType(const hipdnn_data_sdk::data_objects::DataType &type)#

Convert SDK DataType to frontend DataType.

inline hipdnn_data_sdk::data_objects::DiagonalAlignment toSdkType(const DiagonalAlignment &type)#

Convert frontend DiagonalAlignment to SDK DiagonalAlignment.

inline hipdnn_frontend::DiagonalAlignment fromSdkType(const hipdnn_data_sdk::data_objects::DiagonalAlignment &type)#

Convert SDK DiagonalAlignment to frontend DiagonalAlignment.

inline hipdnn_data_sdk::data_objects::AttentionImplementation toSdkType(const AttentionImplementation &type)#

Convert frontend AttentionImplementation to SDK AttentionImplementation.

inline hipdnn_frontend::AttentionImplementation fromSdkType(const hipdnn_data_sdk::data_objects::AttentionImplementation &type)#

Convert SDK AttentionImplementation to frontend AttentionImplementation.

inline std::optional<hipdnnDataType_t> toHipdnnDataType(const DataType &type)#

Convert frontend DataType to backend hipdnnDataType_t.

Parameters:

type – The frontend DataType value

Returns:

The corresponding hipdnnDataType_t value, or std::nullopt if not set

inline std::pair<DataType, Error> fromHipdnnDataType(hipdnnDataType_t type)#

Convert backend hipdnnDataType_t to frontend DataType.

Maps the backend C API data type enum to the frontend DataType enum.

Parameters:

type – The backend hipdnnDataType_t value

Returns:

A pair of the corresponding DataType and an Error (set if the type is unknown)

inline hipdnn_data_sdk::data_objects::PointwiseMode toSdkType(const PointwiseMode &type)#

Convert frontend PointwiseMode to SDK PointwiseMode.

inline hipdnn_frontend::PointwiseMode fromSdkType(const hipdnn_data_sdk::data_objects::PointwiseMode &type)#

Convert SDK PointwiseMode to frontend PointwiseMode.

inline std::pair<PointwiseMode, Error> fromHipdnnPointwiseMode(hipdnnPointwiseMode_t mode)#

Convert backend C-API hipdnnPointwiseMode_t to frontend PointwiseMode.

inline hipdnnBackendHeurMode_t toBackendType(const HeuristicMode &type)#

Convert frontend HeuristicMode to backend heuristic mode.

inline const char *to_string(const ConvolutionMode &mode)#

Convert ConvolutionMode to a human-readable string.

Parameters:

mode – The convolution mode to convert

Returns:

A C-string representation of the convolution mode

inline std::ostream &operator<<(std::ostream &os, const ConvolutionMode &mode)#

Stream insertion operator for ConvolutionMode.

inline const char *to_string(const DataType &type)#

Get a human-readable string for a DataType value.

inline std::ostream &operator<<(std::ostream &os, const DataType &type)#

Stream insertion operator for DataType.

inline const char *to_string(const BuildPlanPolicy &policy)#

Get a human-readable string for a BuildPlanPolicy value.

inline std::ostream &operator<<(std::ostream &os, const BuildPlanPolicy &policy)#

Stream insertion operator for BuildPlanPolicy.

inline const char *to_string(const HeuristicMode &mode)#

Get a human-readable string for a HeuristicMode value.

inline std::ostream &operator<<(std::ostream &os, const HeuristicMode &mode)#

Stream insertion operator for HeuristicMode.

inline hipdnn_data_sdk::data_objects::KnobValue toSdkType(const KnobValueType &type)#

Convert frontend KnobValueType to SDK KnobValue.

inline hipdnn_frontend::KnobValueType fromSdkType(const hipdnn_data_sdk::data_objects::KnobValue &type)#

Convert SDK KnobValue to frontend KnobValueType.

inline hipdnn_data_sdk::data_objects::NormFwdPhase toSdkType(const NormFwdPhase &type)#

Convert frontend NormFwdPhase to SDK NormFwdPhase.

inline hipdnn_frontend::NormFwdPhase fromSdkType(const hipdnn_data_sdk::data_objects::NormFwdPhase &type)#

Convert SDK NormFwdPhase to frontend NormFwdPhase.

inline hipdnn_data_sdk::data_objects::ReductionMode toSdkType(const ReductionMode &type)#

Convert frontend ReductionMode to SDK ReductionMode.

inline hipdnn_frontend::ReductionMode fromSdkType(const hipdnn_data_sdk::data_objects::ReductionMode &type)#

Convert SDK ReductionMode to frontend ReductionMode.

inline const char *to_string(const KnobValueType &type)#

Get a human-readable string for a KnobValueType value.

inline std::ostream &operator<<(std::ostream &os, const KnobValueType &type)#

Stream insertion operator for KnobValueType.

inline const char *to_string(const NormFwdPhase &phase)#

Get a human-readable string for a NormFwdPhase value.

inline std::ostream &operator<<(std::ostream &os, const NormFwdPhase &phase)#

Stream insertion operator for NormFwdPhase.

template<typename ...Ts>
inline KnobValueType getKnobValueTypeFromVariant(const std::variant<Ts...> &value)#

Determine the KnobValueType from a variant’s active alternative.

Template Parameters:

Ts – Variant alternative types

Parameters:

value – The variant to inspect

Returns:

The KnobValueType matching the currently held type

inline bool isUnaryPointwiseMode(PointwiseMode mode)#

Check if a pointwise mode is a unary operation (1 input)

Parameters:

mode – The pointwise mode to check

Returns:

true if the mode is unary, false otherwise

inline bool isBinaryPointwiseMode(PointwiseMode mode)#

Check if a pointwise mode is a binary operation (2 inputs)

Parameters:

mode – The pointwise mode to check

Returns:

true if the mode is binary, false otherwise

inline bool isTernaryPointwiseMode(PointwiseMode mode)#

Check if a pointwise mode is a ternary operation (3 inputs)

Parameters:

mode – The pointwise mode to check

Returns:

true if the mode is ternary, false otherwise

inline const auto &getUnaryModesBitset()#

Get the bitset of all unary pointwise modes.

inline const auto &getBinaryModesBitset()#

Get the bitset of all binary pointwise modes.

inline const auto &getTernaryModesBitset()#

Get the bitset of all ternary pointwise modes.