ITensorStaticsNative.CreateFromD3D12Resource 方法

根据用户指定的 ID3D12Resource 创建 tensor 对象(TensorFloatTensorInt32Bit)。

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

参数

名称 类型 DESCRIPTION
价值 ID3D12资源* 要从中创建张量的 ID3D12Resource
形状 __int64* 张量的形状。
形状计数 int 张量的维度数。
结果 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 上提出问题。