Open Nietaa opened 1 year ago
Assuming I'm understanding the ORT API correctly, when you call this overload of CreateTensor
, the OrtValue
does not "own" the contents:
Ort::Value newValue(
Ort::Value::CreateTensor(
memoryInformation,
dmlAllocatorResource,
tensorByteSize,
tensorDimensions.data(),
tensorDimensions.size(),
elementDataType
)
);
And so you wouldn't call ReleaseValue
on it.
The Dml::AllocationInfo
returned from CreateGPUAllocationFromD3DResource
is an opaque COM object that doesn't expose any additional methods. CreateTensorValueUsingD3DResource(..., dmlAllocatorResource)
then returns the dmlEpResourceWrapper
into a ComPtr<IUnknown> executionProviderTensorWrapper;
, which implicitly cleans up the lifetime when done. Note Dml::FreeGpuAllocation
inside ORT just calls the same Release
method on the Dml::AllocationInfo
(indirectly via the ComPtr
destructor).
So I think it's correct 🤔.
Add printing to your dmlAllocatorResourceCleanup and find that it will never be executed. I think it is redundant code. The resources here are released through the external execution of ProviderTensorWrapper. @fdwr
It looks like the
dmlAllocatorResourceCleanup
deleter inCreateTensorValueFromExistingD3DResource()
never gets called (unlessCreateTensor()
throws an exception) since it's being released before the function returns, and serves no purpose. ThusFreeGPUAllocation()
will never be called for the dml resource. There's no call forReleaseValue()
either anywhere in the code.Same code in WinML.