ITensorNative.GetBuffer method

Gets the tensor’s buffer as an array of bytes.

HRESULT GetBuffer(
    [out, size_is(, *capacity)] BYTE **value,
    [out] UINT32 *capacity);

Parameters

Name Type Description
value BYTE** The tensor's buffer.
capacity UINT32* The capacity of the buffer.

Returns

HRESULT The result of the operation.

Examples

TensorFloat SoftwareBitmapToSoftwareTensor(SoftwareBitmap softwareBitmap)
{
    // 1. Get access to the buffer of softwareBitmap
    BYTE* pData = nullptr;
    UINT32 size = 0;
    BitmapBuffer spBitmapBuffer(softwareBitmap.LockBuffer(BitmapBufferAccessMode::Read));
    winrt::Windows::Foundation::IMemoryBufferReference reference = spBitmapBuffer.CreateReference();
    auto spByteAccess = reference.as<::Windows::Foundation::IMemoryBufferByteAccess>();
    CHECK_HRESULT(spByteAccess->GetBuffer(&pData, &size));

    // ...
}

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.