ITensorStaticsNative.CreateFromD3D12Resource 方法

从用户指定的 ID3D12Resource 创建张量对象(TensorFloatTensorInt32Bit)。

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

参数

客户 Type 说明
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 上提交问题。