hipDNN frontend utilities C++ API#
2026-03-31
4 min read time
Helpers for creating tensor descriptors and handling backend errors.
In hipDNN, tensors passed to graph operations are described by TensorAttributes — lightweight metadata objects that hold shape (dims), memory layout (strides), and data type, but not the actual data. Think of them as tensor metadata (dtype, shape, stride) without the underlying storage — a descriptor, not the data itself.
The makeTensorAttributes() helpers create these descriptors from shapes you provide or from existing Data SDK Tensor objects.
Defines
-
HIPDNN_RETURN_ON_BACKEND_FAILURE(backend_status, error_message)#
Return an Error if a backend call fails, including the backend error string.
- Parameters:
backend_status – The hipdnnStatus_t returned by the backend call
error_message – A human-readable description of the failed operation
-
namespace hipdnn_frontend
-
namespace graph
Functions
-
template<class T, class HostAlloc = hipdnn_data_sdk::utilities::HostAllocator<T>, class DeviceAlloc = hipdnn_data_sdk::utilities::DeviceAllocator<T>>
inline TensorAttributes makeTensorAttributes(const std::string &name, DataType dataType, const hipdnn_data_sdk::utilities::Tensor<T, HostAlloc, DeviceAlloc> &tensor)# Create TensorAttributes by copying shape and layout from an existing Tensor.
Extracts dims and strides from a Data SDK Tensor object. Useful when you already have allocated test tensors and want matching descriptors.
- Template Parameters:
T – Element type of the source tensor (e.g. float, half)
- Parameters:
name – Human-readable name for debugging and serialization
dataType – The numeric precision (e.g. DataType::HALF)
tensor – Source tensor whose dims and strides are copied
- Returns:
Configured TensorAttributes ready to pass to Graph operations
-
inline TensorAttributes makeTensorAttributes(const std::string &name, DataType dataType, const std::vector<int64_t> &dims, const std::vector<int64_t> &strides)#
Create TensorAttributes from explicit dimensions, strides, and data type.
This is the most common way to describe a tensor when you know the shape and precision up front.
- Parameters:
name – Human-readable name for debugging and serialization
dataType – The numeric precision (e.g. DataType::FLOAT)
dims – Tensor dimensions, e.g. {N, C, H, W}
strides – Memory strides for each dimension
- Returns:
Configured TensorAttributes ready to pass to Graph operations
-
inline TensorAttributes makeTensorAttributes(const std::string &name, const std::vector<int64_t> &dims, const std::vector<int64_t> &strides)#
Create TensorAttributes without specifying a data type.
The data type is left unset and will be inferred from the Graph’s
io_data_typeat build time. Handy when all tensors in your graph share the same precision.- Parameters:
name – Human-readable name for debugging and serialization
dims – Tensor dimensions, e.g. {N, C, H, W}
strides – Memory strides for each dimension
- Returns:
TensorAttributes whose data type will be filled at build time
-
template<typename T>
inline TensorAttributes makeTensorAttributes(const std::string &name, const T value)# Create TensorAttributes from a single constant value.
The data type will be set from the type of the value. Useful for tensors that contain single constants, for example an epsilon.
- Parameters:
name – Human-readable name for debugging and serialization
value – Constant value to be inserted into the tensor
- Returns:
Configured TensorAttributes ready to pass to Graph operations
-
inline std::unique_ptr<hipdnn_data_sdk::utilities::ITensor> createTensorFromAttribute(const TensorAttributes &attribute)#
Allocate a Data SDK ITensor that matches the given attributes.
Creates an actual tensor object from a descriptor. Host memory is allocated immediately; device memory is allocated lazily on first access. Primarily used in tests and utilities — in production code you typically manage your own device memory and just pass pointers via the variant pack.
- Parameters:
attribute – The tensor descriptor (type, dims, strides)
- Returns:
Owning pointer to the created ITensor
-
template<class T, class HostAlloc = hipdnn_data_sdk::utilities::HostAllocator<T>, class DeviceAlloc = hipdnn_data_sdk::utilities::DeviceAllocator<T>>
-
namespace graph