Explore the comprehensive list of operators available in DirectML for accelerating machine learning workloads on Windows.
DirectML (Direct Machine Learning) is a high-performance, hardware-accelerated machine learning inference and training API for Windows. It provides a standardized way for applications to leverage the power of DirectX 12-compatible GPUs for machine learning tasks.
The DirectML operator model defines a rich set of building blocks that can be composed to create complex neural network architectures. This page provides an overview of available operators, their categories, and how to use them.
DirectML operators are broadly categorized to help you find the functionality you need:
Here's a selection of frequently used DirectML operators:
Performs a convolution operation, a fundamental building block for CNNs.
Applies the Rectified Linear Unit activation function element-wise.
Performs max pooling over an input tensor.
Performs element-wise addition of two tensors.
Performs matrix multiplication between two tensors.
Normalizes the activations across a batch dimension.
Applies the softmax function, often used in output layers for classification.
Each DirectML operator has a specific signature and set of properties. When defining an operator in your DirectML graph, you typically specify input tensors, output tensors, and operator-specific attributes.
Consider defining a 2D convolution. The syntax often involves creating an operator object and setting its properties:
// Assuming 'device' is your IDMLDevice and 'context' is your IDMLCommandRecorder
DML_CONVOLUTION_OPERATOR_DESC convDesc = new DML_CONVOLUTION_OPERATOR_DESC();
convDesc.InputTensor = &inputTensorDesc; // Pointer to input tensor description
convDesc.FilterTensor = &filterTensorDesc; // Pointer to filter tensor description
convDesc.OutputTensor = &outputTensorDesc; // Pointer to output tensor description
convDesc.Mode = DML_CONVOLUTION_MODE_DEFAULT;
convDesc.Direction = DML_CONVOLUTION_DIRECTION_FORWARD;
convDesc.DimensionCount = 2; // For 2D convolution
convDesc.Strides = new uint[] { 1, 1 }; // Example strides
convDesc.Dilations = new uint[] { 1, 1 }; // Example dilations
convDesc.Padding = new DML_PADDING_BORDER_DESC[]
{
new DML_PADDING_BORDER_DESC { Type = DML_BORDER_TYPE_CONSTANT, Value = 0 },
new DML_PADDING_BORDER_DESC { Type = DML_BORDER_TYPE_CONSTANT, Value = 0 }
};
convDesc.OutputPadding = new uint[] { 0, 0 };
convDesc.Groups = 1;
// Create the operator
IDMLOperator* convolutionOperator;
device->CreateOperator(&convDesc, IID_PPV_ARGS(&convolutionOperator));
For a complete list of operators and their detailed parameters, please refer to the official DirectML Operator Reference.
To integrate DirectML operators into your application:
IDMLDevice and an IDMLCommandRecorder.DML_TENSOR_DESC.DML_*_OPERATOR_DESC structures and IDMLDevice::CreateOperator.Explore the DirectML Samples repository on GitHub for practical examples and best practices.