ITensorStaticsNative.CreateFromD3D12Resource method

Creates a tensor object (TensorFloat, TensorInt32Bit) from a user-specified ID3D12Resource.

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

Parameters

Name Type Description
value ID3D12Resource* The ID3D12Resource from which to create the tensor.
shape __int64* The shape of the tensor.
shapeCount int The number of dimensions of the tensor.
result IUnknown** The resulting tensor.

Returns

HRESULT The result of the operation.

Examples

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);

    // ...
}

See also

Requirements

Requirement
Minimum supported client Windows 10, build 17763
Minimum supported server Windows Server 2019 with Desktop Experience
Header windows.ai.machinelearning.native.h

Note

Use the following resources for help with Windows ML:

  • To ask or answer technical questions about Windows ML, please use the windows-machine-learning tag on Stack Overflow.
  • To report a bug, please file an issue on our GitHub.