IDMLBindingTable::BindPersistentResource method (directml.h)
Binds a buffer as a persistent resource. You can determine the required size of this buffer range by calling IDMLDispatchable::GetBindingProperties.
If the binding properties for the operator specify a size of zero for the persistent resource, then you may supply nullptr to this method (which indicates no resource to bind). Otherwise, a binding of type DML_BINDING_TYPE_BUFFER must be supplied that is at least as large as the required PersistentResourceSize returned by IDMLDispatchable::GetBindingProperties.
Unlike the temporary resource, the persistent resource's contents and lifetime must persist as long as the compiled operator does. That is, if an operator requires a persistent resource, then your application must supply it during initialization and subsequently also supply it to all future executes of the operator without modifying its contents.
The persistent resource is typically used by DirectML to store lookup tables or other long-lived data that is computed during initialization of an operator and reused on future executions of that operator.
As the persistent resource's data is opaque, once initialized it cannot be copied or moved to another buffer.
The persistent resource is only written to during initialization of an operator and is thereafter immutable; all subsequent executions are guaranteed not to write to the persistent resource.
The supplied buffer range to be bound as the persistent buffer must have its start offset aligned to DML_PERSISTENT_BUFFER_ALIGNMENT. The type of the heap underlying the buffer must be D3D12_HEAP_TYPE_DEFAULT.
Syntax
void BindPersistentResource(
[in, optional] const DML_BINDING_DESC *binding
);
Parameters
[in, optional] binding
Type: const DML_BINDING_DESC*
An optional pointer to a DML_BINDING_DESC containing the description of a tensor resource to bind.
Return value
None
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Header | directml.h |
Library | DirectML.lib |
DLL | DirectML.dll |