ILearningModelDeviceFactoryNative.CreateFromD3D12CommandQueue 方法

创建一个 LearningModelDevice ,它将在用户指定的 ID3D12CommandQueue 上运行推理。

HRESULT CreateFromD3D12CommandQueue(
    ID3D12CommandQueue * value,
    [out] IUnknown ** result);

参数

名称 类型 DESCRIPTION
价值 ID3D12CommandQueue* 将对其运行 LearningModelDeviceID3D12CommandQueue
结果 IUnknown** 要创建的 LearningModelDevice

退货

HRESULT 操作的结果。

例子

 // 1. create the d3d device.
com_ptr<ID3D12Device> pD3D12Device = nullptr;
CHECK_HRESULT(D3D12CreateDevice(
    nullptr,
    D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0,
    __uuidof(ID3D12Device),
    reinterpret_cast<void**>(&pD3D12Device)));

// 2. create the command queue.
com_ptr<ID3D12CommandQueue> dxQueue = nullptr;
D3D12_COMMAND_QUEUE_DESC commandQueueDesc = {};
commandQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
CHECK_HRESULT(pD3D12Device->CreateCommandQueue(
    &commandQueueDesc,
    __uuidof(ID3D12CommandQueue),
    reinterpret_cast<void**>(&dxQueue)));
com_ptr<ILearningModelDeviceFactoryNative> devicefactory =
    get_activation_factory<LearningModelDevice, ILearningModelDeviceFactoryNative>();
com_ptr<::IUnknown> spUnk;
CHECK_HRESULT(devicefactory->CreateFromD3D12CommandQueue(dxQueue.get(), spUnk.put()));

另请参阅

要求

要求
最低支持的客户端 Windows 10 版本 17763
支持的最低服务器 具有桌面体验的 Windows Server 2019
标头 windows.ai.machinelearning.native.h

注释

使用以下资源获取有关 Windows ML 的帮助:

  • 若要提出或回答有关 Windows ML 的技术问题,请在 Stack Overflow 上使用 windows-machine-learning 标记。
  • 若要报告 bug,请在 GitHub 上提交问题。