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
NvSciBufAttrListby passing a set ofNvMediaTensorallocation attributes and anNvMediaTypeas input toNvMediaTensorFillNvSciBufAttrs(). - The application may set any of the public
NvSciBufAttributevalues 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
NvSciBufObjobject has to be shared with other user mode drivers (UMDs), the application can get the correspondingNvSciBufAttrListfrom the respective UMDs. - The application asks NvSciBuf to reconcile all of the filled
NvSciBufAttrListobjects, then allocates an NvSciBuf object. - The application queries NvMedia to create an
NvMediaTensorfrom the allocated NvSciBuf object by callingNvMediaTensorCreateFromNvSciBuf(). - The
NvMediaTensorcan be passed as input and output to any of the NvMedia API functions that accept anNvMediaTensoras a parameter.