Add some more documentation for the C/C++ API tensor creation functions. (#10394)

This commit is contained in:
Edward Chen 2022-01-27 13:19:11 -08:00 committed by GitHub
parent 481b96d32a
commit 0e951d7d6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 18 deletions

View file

@ -1149,8 +1149,8 @@ struct OrtApi {
* Create a tensor using a supplied ::OrtAllocator
*
* \param[in] allocator
* \param[in] shape Tensor shape
* \param[in] shape_len Number of elements in `shape`
* \param[in] shape Pointer to the tensor shape dimensions.
* \param[in] shape_len The number of tensor shape dimensions.
* \param[in] type
* \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue
*
@ -1160,20 +1160,20 @@ struct OrtApi {
ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
/** \brief Create a tensor backed by a user supplied buffer
*
* Create a tensor with user's buffer. You can fill the buffer either before calling this function or after.
* p_data is owned by caller. ReleaseValue won't release p_data.
*
* \param[in] info
* \param[in] p_data
* \param[in] p_data_len
* \param[in] shape
* \param[in] shape_len
* \param[in] type
* \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue
*
* Create a tensor with user's buffer. You can fill the buffer either before calling this function or after.
* p_data is owned by caller. ReleaseValue won't release p_data.
*
* \param[in] info Memory description of where the p_data buffer resides (CPU vs GPU etc).
* \param[in] p_data Pointer to the data buffer.
* \param[in] p_data_len The number of bytes in the data buffer.
* \param[in] shape Pointer to the tensor shape dimensions.
* \param[in] shape_len The number of tensor shape dimensions.
* \param[in] type The data type.
* \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*/
*/
ORT_API2_STATUS(CreateTensorWithDataAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
size_t p_data_len, _In_ const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type,
_Outptr_ OrtValue** out);

View file

@ -511,10 +511,25 @@ struct Value : Base<OrtValue> {
size_t shape_len;
};
/// \brief Wraps OrtApi::CreateTensorWithDataAsOrtValue
/** \brief Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.
* \tparam T The numeric datatype. This API is not suitable for strings.
* \param info Memory description of where the p_data buffer resides (CPU vs GPU etc).
* \param p_data Pointer to the data buffer.
* \param p_data_element_count The number of elements in the data buffer.
* \param shape Pointer to the tensor shape dimensions.
* \param shape_len The number of tensor shape dimensions.
*/
template <typename T>
static Value CreateTensor(const OrtMemoryInfo* info, T* p_data, size_t p_data_element_count, const int64_t* shape, size_t shape_len);
/// \brief Wraps OrtApi::CreateTensorWithDataAsOrtValue
/** \brief Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.
* \param info Memory description of where the p_data buffer resides (CPU vs GPU etc).
* \param p_data Pointer to the data buffer.
* \param p_data_byte_count The number of bytes in the data buffer.
* \param shape Pointer to the tensor shape dimensions.
* \param shape_len The number of tensor shape dimensions.
* \param type The data type.
*/
static Value CreateTensor(const OrtMemoryInfo* info, void* p_data, size_t p_data_byte_count, const int64_t* shape, size_t shape_len,
ONNXTensorElementDataType type);
@ -586,10 +601,21 @@ struct Value : Base<OrtValue> {
#endif // !defined(DISABLE_SPARSE_TENSORS)
// \brief Wraps OrtApi::CreateTensorAsOrtValue
/** \brief Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.
* \tparam T The numeric datatype. This API is not suitable for strings.
* \param allocator The allocator to use.
* \param shape Pointer to the tensor shape dimensions.
* \param shape_len The number of tensor shape dimensions.
*/
template <typename T>
static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len);
// \brief Wraps OrtApi::CreateTensorAsOrtValue
/** \brief Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.
* \param allocator The allocator to use.
* \param shape Pointer to the tensor shape dimensions.
* \param shape_len The number of tensor shape dimensions.
* \param type The data type.
*/
static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type);
#if !defined(DISABLE_SPARSE_TENSORS)