共用方式為


ITensorStaticsNative.CreateFromD3D12Resource 方法

從使用者指定的 ID3D12Resource 建立 TensorFloat TensorInt32Bit

HRESULT CreateFromD3D12Resource(
    ID3D12Resource *value,
    [size_is(shapeCount)] __int64 *shape,
    int shapeCount,
    [out] IUnknown ** result);

參數

姓名 類型​​ 描述
value ID3D12Resource* 要從中建立張量的 ID3D12Resource
shape __int64* 張量的形狀。
shapeCount int 張量維度的數目。
result IUnknown** 產生的張量。

傳回

HRESULT 作業的結果。

範例

TensorFloat SoftwareBitmapToDX12Tensor(SoftwareBitmap softwareBitmap)
{
    // ...

    // GPU tensorize
    com_ptr<ITensorStaticsNative> tensorfactory = get_activation_factory<TensorFloat, ITensorStaticsNative>();
    com_ptr<::IUnknown> spUnkTensor;
    TensorFloat input1imagetensor(nullptr);
    int64_t shapes[4] = { 1,3, softwareBitmap.PixelWidth(), softwareBitmap.PixelHeight() };
    CHECK_HRESULT(tensorfactory->CreateFromD3D12Resource(pGPUResource.get(), shapes, 4, spUnkTensor.put()));
    spUnkTensor.try_as(input1imagetensor);

    // ...
}

另請參閱

需求

需求
最低支援的用戶端 Windows 10 組建 17763
最低支援的伺服器 具有桌面體驗的 Windows Server 2019
頁首 windows.ai.machinelearning.native.h

注意

使用下列資源取得 Windows ML 的說明:

  • 如需詢問或回答有關 Windows ML 的技術問題,請使用 Stack Overflow 上的 windows-machine-learning 標籤。
  • 如需回報錯誤 (bug),請在 GitHub 上提出問題。