NvMediaTensorCreateFromNvSciBuf()
Creates an NvMedia Tensor handle from an NvSciBuf
created with the NvSciBuf API, after the required NvSciBuf attributes list is prepared.
Every hardware engine in an NVIDIA SoC can have a different alignment or stride constraints. Hence, sharing a buffer across various engines requires that buffer allocation satisfies the constraints of all of the engines that share the buffer. An engine whose constraints are not satisfied may fail to operate on the buffer. The allocation functions provided by the various NvMedia drivers only satisfy the constraints of the engines that are visible to them, and so cannot be used to allocate shared buffers.
NvSciBuf is a buffer allocation module that satisfies a common set of constraints that are compatible with all of the hardware engines. It thus can allocate buffers that are shareable across the hardware engines visible to various drivers.
This is a typical flow to allocate an NvSciBufObj
, which can be mapped to an NvMediaTensor
:
- The application creates an
NvSciBufAttrList
. - The application queries NvMedia to fill the
NvSciBufAttrList
by passing a set ofNvMediaTensor
allocation attributes and anNvMediaType
as input toNvMediaTensorFillNvSciBufAttrs()
. - The application may set any of the public
NvSciBufAttribute
values that NvMedia does not set.For more details on NvSciBuf concepts, terminology, and the API, see Buffer Allocation.
The following NvSciBuf input attributes are set by NvMedia, and must not be set by the application:
- NvSciBufGeneralAttrKey_Types
- NvSciBufGeneralAttrKey_NeedCpuAccess
- NvSciBufGeneralAttrKey_EnableCpuCache
- NvSciBufTensorAttrKey_DataType
- NvSciBufTensorAttrKey_NumDims
- NvSciBufTensorAttrKey_SizePerDim
- NvSciBufTensorAttrKey_AlignmentPerDim
- NvSciBufTensorAttrKey_StridesPerDim
- NvSciBufTensorAttrKey_PixelFormat
- NvSciBufTensorAttrKey_BaseAddrAlign
The following attributes are not set by NvMedia and must be set by the application:- NvSciBufGeneralAttrKey_RequiredPerm
- If the same
NvSciBufObj
object has to be shared with other user mode drivers (UMDs), the application can get the correspondingNvSciBufAttrList
from the respective UMDs. - The application asks NvSciBuf to reconcile all of the filled
NvSciBufAttrList
objects, then allocates an NvSciBuf object. - The application queries NvMedia to create an
NvMediaTensor
from the allocated NvSciBuf object by callingNvMediaTensorCreateFromNvSciBuf()
. - The
NvMediaTensor
can be passed as input and output to any of the NvMedia API functions that accept anNvMediaTensor
as a parameter.