IDMLDevice1::CompileGraph method (directml.h)
Compiles a graph of DirectML operators into an object that can be dispatched to the GPU.
A compiled operator represents the efficient, baked form of an operator suitable for execution on the GPU. A compiled operator holds state (such as shaders and other objects) required for execution. Because a compiled operator implements the IDMLPageable interface, you're able to evict one from GPU memory if you wish. See IDMLDevice1::Evict and IDMLDevice1::MakeResident for more info.
The compiled operator doesn't use nor reference the IDMLOperator objects supplied within the graph description after this method returns.
Syntax
HRESULT CompileGraph(
const DML_GRAPH_DESC *desc,
DML_EXECUTION_FLAGS flags,
REFIID riid,
[out] void **ppv
);
Parameters
desc
Type: DML_GRAPH_DESC*
A description of the graph to compile. See DML_GRAPH_DESC.
flags
Type: DML_EXECUTION_FLAGS
Any flags to control the execution of this operator.
riid
Type: REFIID
A reference to the globally unique identifier (GUID) of the interface that you wish to be returned in ppv. This is expected to be the GUID of IDMLCompiledOperator.
[out] ppv
Type: void**
A pointer to a memory block that receives a pointer to the compiled operator. This is the address of a pointer to an IDMLCompiledOperator, representing the compiled operator created.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
The DirectML operator graph API provides an abstract way to use DirectML efficiently across diverse hardware. DirectML applies tensor-level optimizations such as choosing the most efficient tensor layout based on the adapter being used. It also applies optimizations such as the removal of Join or Split operators.
We recommend that you apply high-level optimizations before building a DirectML graph. For example, fusing Convolution operators with BatchNorm, constant folding, and common subexpression elimination. The optimizations within DirectML's graph optimizer are intended to complement such device-independent optimizations, which are typically handled generically by machine learning frameworks.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 10 Build 20348 |
Minimum supported server | Windows 10 Build 20348 |
Target Platform | Windows |
Header | directml.h |
Library | DirectML.lib |
DLL | DirectML.dll |