简体   繁体   中英

How do I convert a winrt::Microsoft::AI::MachineLearning::TensorFloat type back to ID3D12Resource

I am loading an image to the GPU by leveraging ID3D12Resource type. And I found some documentation on how to convert the ID3D12Resource to a Microsoft::AI::MachineLearning::TensorFloat in the Microsoft documentation , but I can't seem to find how to revert it back to ID3D12Resource .

I am following the Machine Learning samples from Microsoft documentation, and the output from the model evaluation is a Microsoft::AI::MachineLearning::TensorFloat type:

https://github.com/microsoft/Windows-Machine-Learning/blob/e901cc2791f4f3d22e2382e779996bad49173718/Samples/AdapterSelection/AdapterSelection/cpp/main.cpp#L110

How do I take the model output that is a TensorFloat type and convert it back to ID3D12Resource . Ideally, I would like to override the content from the original ID3D12Resource input with the return of the model.

Thank you for your help :)

In order to get the model's output as a D3D12Resource type you can just do the following:

com_ptr<ID3D12Resource> resultResource;
results.Outputs().Lookup(outputName).as<ITensorNative>()->GetD3D12Resource( resultResource.put() );

Documentation reference:

https://docs.microsoft.com/en-us/windows/ai/windows-ml/native-apis/itensornative_getd3d12resource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM