muDNN API Reference
1 Introduction
The Moore Threads® MUSA® Deep Neural Network(muDNN) library is a GPU-accelerated library for common- used primitives in deep neural networks. muDNN provides highly optimized functions that can be used to perform various mathematical and data processing tasks, such as:
- Tensor operations: element-wise operations, matrix operations, reduction operations, etc.
- Neural network layers: convolution, pooling, normalization, activation, etc.
- Loss functions: KLDivLoss, L2Loss, NLLLoss, etc. It enables users to focus on training neural networks and developing applications rather than accelerating GPU performance. muDNN library offers a context-based API that allows for easy multithreading with MUSA streams.
This API Reference lists the data type definitions and detailed descriptions of functions.
1.1 Functional requirements and assurances
- Each API could be accessed safely and concurrently, i.e. they are reentrant. Users must ensure that the necessary input memory allocation and data preparation are ready before calling the API.
- Most APIs (except specific ones with annotation) could reproduce the same result with identical configuration and input.
- muDNN supports a maximum tensor dimension of size 8.
2 Module Index
2.1 Modules
Here is a list of all modules:
- Base Operators
- Image Operators
- Math Operators
- NN -(Neural Network) Operators
- Version
3 Class Index
3.1 Class List
- musa::dnn::BatchMatMul Here are the classes, structs, unions and interfaces with brief descriptions:
- musa::dnn::BatchNorm
- musa::dnn::Binary
- musa::dnn::Concat
- musa::dnn::Convolution
- musa::dnn::CTCLoss
- musa::dnn::Cum
- musa::dnn::Cumsum
- musa::dnn::DebugInfo
- musa::dnn::DeformableConv
- musa::dnn::Dot
- musa::dnn::Dropout
- musa::dnn::Fill
- musa::dnn::Convolution::FusedActivationDesc
- musa::dnn::GatherX
- musa::dnn::Glu
- musa::dnn::GroupNorm
- musa::dnn::Handle
- musa::dnn::ImplBase
- musa::dnn::Interpolate
- musa::dnn::KLDivLoss
- musa::dnn::L2Loss
- musa::dnn::LayerNorm
- musa::dnn::LocalResponseNorm
- musa::dnn::MaskedScatter
- musa::dnn::MaskedSelect
- musa::dnn::MatMul
- musa::dnn::MatrixBase
- musa::dnn::MultiHeadAttention
- musa::dnn::NLLLoss
- musa::dnn::Nonzero
- musa::dnn::Pad
- musa::dnn::Permute
- musa::dnn::Pooling
- musa::dnn::Reduce
- musa::dnn::RMSNorm
- musa::dnn::RNN
- musa::dnn::ScaledDotProductAttention
- musa::dnn::Scan
- musa::dnn::Scatter
- musa::dnn::ScatterND
- musa::dnn::Softmax
- musa::dnn::Sort
- musa::dnn::SortByKey
- musa::dnn::Tensor
- musa::dnn::TensorBase
- musa::dnn::Ternary
- musa::dnn::TopK
- musa::dnn::Unary
- musa::dnn::Unfold
- musa::dnn::Unique
- musa::dnn::WeightNorm
4 Module Documentation
4.1 Base Operators
Classes
- class musa::dnn::ImplBase
- class musa::dnn::Handle
- class musa::dnn::TensorBase
- class musa::dnn::Tensor
- class musa::dnn::MatrixBase
- class musa::dnn::DebugInfo
Macros
- #define MUDNN_ITEM (x) x,
- #define MUDNN_ITEM (x, ...) x,
- #define MUDNN_ITEM (x) x,
- #define MUDNN_ITEM (x) x,
- #define MUDNN_ITEM (x, y) x,
Typedefs
- using **musa::dnn::MemoryHandler** = std::unique_ptr<void, std::function<void(void∗)>>
- using **musa::dnn::MemoryMaintainer** = std::function<MemoryHandler(size_t)>
- using **musa::dnn::CallBack** = std::function<void(DebugInfo::Severity, void∗user_data, const DebugInfo
&dbg, const char∗message)>
Enumerations
- enum class **Status** { **MUDNN_ITEM** }
- enum class **Type** { **MUDNN_ITEM** }
- enum class **Format** { **MUDNN_ITEM** }
- enum class **ComputeMode** { **MUDNN_ITEM** }
- enum class **Severity** { **MUDNN_ITEM** }
Functions
- void∗ **musa::dnn::ImplBase::GetImpl** ()
- const void∗ **musa::dnn::ImplBase::GetImpl** () const
- **musa::dnn::ImplBase::ImplBase** (void∗impl)
- **musa::dnn::ImplBase::ImplBase** (const ImplBase &)=delete
- **musa::dnn::ImplBase::ImplBase** (ImplBase &&)=delete
- ImplBase & **musa::dnn::ImplBase::operator=** (const ImplBase &)=delete
- ImplBase & **musa::dnn::ImplBase::operator=** (ImplBase &&)=delete
- **musa::dnn::Handle::Handle** (int device_id)
- int **musa::dnn::Handle::GetDeviceId** () const
- Status **musa::dnn::Handle::SetStream** (musaStream_t stream)
- musaStream_t **musa::dnn::Handle::GetStream** () const
- Status **musa::dnn::Handle::SetAllowTF32** (bool allow_tf32)
- bool **musa::dnn::Handle::GetAllowTF32** () const
- **musa::dnn::Tensor::Tensor** (const Tensor &)
- **musa::dnn::Tensor::Tensor** (Tensor &&)
- Tensor & **musa::dnn::Tensor::operator=** (const Tensor &)
- Tensor & **musa::dnn::Tensor::operator=** (Tensor &&)
- Status **musa::dnn::Tensor::SetAddr** (const void∗addr)
- Status **musa::dnn::Tensor::SetType** (Type t)
- Status **musa::dnn::Tensor::SetFormat** (Format f)
- Status **musa::dnn::Tensor::SetNdInfo** (std::initializer_list<int64_t>dim)
- Status **musa::dnn::Tensor::SetNdInfo** (int ndims, const int64_t∗dim)
- Status **musa::dnn::Tensor::SetNdInfo** (int64_t ndims, const int64_t∗dim)
- Status **musa::dnn::Tensor::SetNdInfo** (std::initializer_list<int64_t>dim, std::initializer_list<int64_t>
stride)
- Status **musa::dnn::Tensor::SetNdInfo** (int ndims, const int64_t∗dim, const int64_t∗stride)
- Status **musa::dnn::Tensor::SetNdInfo** (int64_t ndims, const int64_t∗dim, const int64_t∗stride)
- Status **musa::dnn::Tensor::GetNdInfo** (std::vector<int64_t>&dim)
- Status **musa::dnn::Tensor::GetNdInfo** (std::vector<int64_t>&dim, std::vector<int64_t>&stride)
- Status **musa::dnn::Tensor::SetQuantizationInfo** (int n, const float∗scales, const unsigned int∗zero_←-
points)
- Status **musa::dnn::Tensor::SetQuantizationInfo** (std::initializer_list<float>scales, std::initializer_list<
unsigned int>zero_points)
- Status **musa::dnn::Tensor::SetQuantizationInfo** (const std::vector<float>&scales)
- Status **musa::dnn::Tensor::CopyFrom** (void∗ptr, size_t bytes, int kind, Handle &h, bool sync=false)
- Status **musa::dnn::Tensor::CopyTo** (void∗ptr, size_t bytes, int kind, Handle &h, bool sync=false) const
- MUDNN_EXPORT Status **musa::dnn::SetCallBack** (DebugInfo::Severity min, void∗udata, CallBack f)
Variables
- void∗ musa::dnn::ImplBase::impl_
- uint32_t musa::dnn::DebugInfo::version
- Severity musa::dnn::DebugInfo::severity
- uint32_t musa::dnn::DebugInfo::time_sec
- uint32_t musa::dnn::DebugInfo::time_usec
- uint32_t musa::dnn::DebugInfo::time_delta
- uint64_t musa::dnn::DebugInfo::tid
- int32_t musa::dnn::DebugInfo::device_id
- const Handle∗ musa::dnn::DebugInfo::handle
4.1.1 Detailed Description
This entity contains basic functionality related to muDNN context creation and destruction, tensor utility routines, tensor core operations, debug logs, and so on.