OnnxRuntime
Ort::Value Struct Reference

#include <onnxruntime_cxx_api.h>

Inherits Ort::Base< OrtValue >.

Classes

struct  OrtSparseValuesParam
 
struct  Shape
 

Public Member Functions

void UseCooIndices (int64_t *indices_data, size_t indices_num)
 Supplies COO format specific indices and marks the contained sparse tensor as being a COO format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. More...
 
void UseCsrIndices (int64_t *inner_data, size_t inner_num, int64_t *outer_data, size_t outer_num)
 Supplies CSR format specific indices and marks the contained sparse tensor as being a CSR format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. More...
 
void UseBlockSparseIndices (const Shape &indices_shape, int32_t *indices_data)
 Supplies BlockSparse format specific indices and marks the contained sparse tensor as being a BlockSparse format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. More...
 
void FillSparseTensorCoo (const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values_param, const int64_t *indices_data, size_t indices_num)
 The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and COO indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible. More...
 
void FillSparseTensorCsr (const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values, const int64_t *inner_indices_data, size_t inner_indices_num, const int64_t *outer_indices_data, size_t outer_indices_num)
 The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and CSR indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible. More...
 
void FillSparseTensorBlockSparse (const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values, const Shape &indices_shape, const int32_t *indices_data)
 The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and BlockSparse indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible. More...
 
OrtSparseFormat GetSparseFormat () const
 The API returns the sparse data format this OrtValue holds in a sparse tensor. If the sparse tensor was not fully constructed, i.e. Use*() or Fill*() API were not used the value returned is ORT_SPARSE_UNDEFINED. More...
 
TensorTypeAndShapeInfo GetSparseTensorValuesTypeAndShapeInfo () const
 The API returns type and shape information for stored non-zero values of the sparse tensor. Use GetSparseTensorValues() to obtain values buffer pointer. More...
 
TensorTypeAndShapeInfo GetSparseTensorIndicesTypeShapeInfo (OrtSparseIndicesFormat format) const
 The API returns type and shape information for the specified indices. Each supported indices have their own enum values even if a give format has more than one kind of indices. Use GetSparseTensorIndicesData() to obtain pointer to indices buffer. More...
 
template<typename T >
const T * GetSparseTensorIndicesData (OrtSparseIndicesFormat indices_format, size_t &num_indices) const
 The API retrieves a pointer to the internal indices buffer. The API merely performs a convenience data type casting on the return type pointer. Make sure you are requesting the right type, use GetSparseTensorIndicesTypeShapeInfo(); More...
 
template<typename T >
void GetOpaqueData (const char *domain, const char *type_name, T &) const
 Wraps OrtApi::GetOpaqueValue. More...
 
 Value (std::nullptr_t)
 Create an empty Value object, must be assigned a valid one to be used. More...
 
 Value (OrtValue *p)
 Used for interop with the C API. More...
 
 Value (Value &&)=default
 
Valueoperator= (Value &&)=default
 
bool IsTensor () const
 Returns true if Value is a tensor, false for other types like map/sequence/etc. More...
 
bool HasValue () const
 
bool IsSparseTensor () const
 < Return true if OrtValue contains data and returns false if the OrtValue is a None More...
 
size_t GetCount () const
 
Value GetValue (int index, OrtAllocator *allocator) const
 
size_t GetStringTensorDataLength () const
 This API returns a full length of string data contained within either a tensor or a sparse Tensor. For sparse tensor it returns a full length of stored non-empty strings (values). The API is useful for allocating necessary memory and calling GetStringTensorContent(). More...
 
void GetStringTensorContent (void *buffer, size_t buffer_length, size_t *offsets, size_t offsets_count) const
 The API copies all of the UTF-8 encoded string data contained within a tensor or a sparse tensor into a supplied buffer. Use GetStringTensorDataLength() to find out the length of the buffer to allocate. The user must also allocate offsets buffer with the number of entries equal to that of the contained strings. More...
 
template<typename T >
T * GetTensorMutableData ()
 Wraps OrtApi::GetTensorMutableData. More...
 
template<typename T >
const T * GetTensorData () const
 Wraps OrtApi::GetTensorMutableData. More...
 
template<typename T >
const T * GetSparseTensorValues () const
 The API returns a pointer to an internal buffer of the sparse tensor containing non-zero values. The API merely does casting. Make sure you are requesting the right data type by calling GetSparseTensorValuesTypeAndShapeInfo() first. More...
 
template<typename T >
T & At (const std::vector< int64_t > &location)
 
TypeInfo GetTypeInfo () const
 The API returns type information for data contained in a tensor. For sparse tensors it returns type information for contained non-zero values. It returns dense shape for sparse tensors. More...
 
TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo () const
 The API returns type information for data contained in a tensor. For sparse tensors it returns type information for contained non-zero values. It returns dense shape for sparse tensors. More...
 
size_t GetStringTensorElementLength (size_t element_index) const
 The API returns a byte length of UTF-8 encoded string element contained in either a tensor or a spare tensor values. More...
 
void GetStringTensorElement (size_t buffer_length, size_t element_index, void *buffer) const
 The API copies UTF-8 encoded bytes for the requested string element contained within a tensor or a sparse tensor into a provided buffer. Use GetStringTensorElementLength() to obtain the length of the buffer to allocate. More...
 
void FillStringTensor (const char *const *s, size_t s_len)
 
void FillStringTensorElement (const char *s, size_t index)
 
- Public Member Functions inherited from Ort::Base< OrtValue >
 Base ()=default
 
 Base (OrtValue *p)
 
 ~Base ()
 
 operator OrtValue * ()
 
 operator const OrtValue * () const
 
OrtValuerelease ()
 Releases ownership of the contained pointer. More...
 

Static Public Member Functions

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)
 Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue. More...
 
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)
 Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue. More...
 
template<typename T >
static Value CreateSparseTensor (const OrtMemoryInfo *info, T *p_data, const Shape &dense_shape, const Shape &values_shape)
 This is a simple forwarding method to the other overload that helps deducing data type enum value from the type of the buffer. More...
 
static Value CreateSparseTensor (const OrtMemoryInfo *info, void *p_data, const Shape &dense_shape, const Shape &values_shape, ONNXTensorElementDataType type)
 Creates an OrtValue instance containing SparseTensor. This constructs a sparse tensor that makes use of user allocated buffers. It does not make copies of the user provided data and does not modify it. The lifespan of user provided buffers should eclipse the life span of the resulting OrtValue. This call constructs an instance that only contain a pointer to non-zero values. To fully populate the sparse tensor call Use<Format>Indices() API below to supply a sparse format specific indices. This API is not suitable for string data. Use CreateSparseTensor() with allocator specified so strings can be properly copied into the allocated buffer. More...
 
template<typename T >
static Value CreateTensor (OrtAllocator *allocator, const int64_t *shape, size_t shape_len)
 Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue. More...
 
static Value CreateTensor (OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type)
 Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue. More...
 
template<typename T >
static Value CreateSparseTensor (OrtAllocator *allocator, const Shape &dense_shape)
 This is a simple forwarding method the below CreateSparseTensor. This helps to specify data type enum in terms of C++ data type. Use CreateSparseTensor<T> More...
 
static Value CreateSparseTensor (OrtAllocator *allocator, const Shape &dense_shape, ONNXTensorElementDataType type)
 Creates an instance of OrtValue containing sparse tensor. The created instance has no data. The data must be supplied by on of the FillSparseTensor<Format>() methods that take both non-zero values and indices. The data will be copied into a buffer that would be allocated using the supplied allocator. Use this API to create OrtValues that contain sparse tensors with all supported data types including strings. More...
 
static Value CreateMap (Value &keys, Value &values)
 Wraps OrtApi::CreateValue. More...
 
static Value CreateSequence (std::vector< Value > &values)
 Wraps OrtApi::CreateValue. More...
 
template<typename T >
static Value CreateOpaque (const char *domain, const char *type_name, const T &)
 Wraps OrtApi::CreateOpaqueValue. More...
 

Additional Inherited Members

- Public Types inherited from Ort::Base< OrtValue >
using contained_type = OrtValue
 
- Protected Member Functions inherited from Ort::Base< OrtValue >
 Base (const Base &)=delete
 
 Base (Base &&v) noexcept
 
Baseoperator= (const Base &)=delete
 
void operator= (Base &&v) noexcept
 
- Protected Attributes inherited from Ort::Base< OrtValue >
OrtValuep_
 

Constructor & Destructor Documentation

◆ Value() [1/3]

Ort::Value::Value ( std::nullptr_t  )
inlineexplicit

Create an empty Value object, must be assigned a valid one to be used.

◆ Value() [2/3]

Ort::Value::Value ( OrtValue p)
inlineexplicit

Used for interop with the C API.

◆ Value() [3/3]

Ort::Value::Value ( Value &&  )
default

Member Function Documentation

◆ At()

template<typename T >
T & Ort::Value::At ( const std::vector< int64_t > &  location)

◆ CreateMap()

static Value Ort::Value::CreateMap ( Value keys,
Value values 
)
static

◆ CreateOpaque()

template<typename T >
static Value Ort::Value::CreateOpaque ( const char *  domain,
const char *  type_name,
const T &   
)
static

◆ CreateSequence()

static Value Ort::Value::CreateSequence ( std::vector< Value > &  values)
static

◆ CreateSparseTensor() [1/4]

template<typename T >
static Value Ort::Value::CreateSparseTensor ( const OrtMemoryInfo info,
T *  p_data,
const Shape dense_shape,
const Shape values_shape 
)
static

This is a simple forwarding method to the other overload that helps deducing data type enum value from the type of the buffer.

Template Parameters
Tnumeric datatype. This API is not suitable for strings.
Parameters
infoMemory description where the user buffers reside (CPU vs GPU etc)
p_datapointer to the user supplied buffer, use nullptr for fully sparse tensors
dense_shapea would be dense shape of the tensor
values_shapenon zero values shape. Use a single 0 shape for fully sparse tensors.
Returns

◆ CreateSparseTensor() [2/4]

static Value Ort::Value::CreateSparseTensor ( const OrtMemoryInfo info,
void *  p_data,
const Shape dense_shape,
const Shape values_shape,
ONNXTensorElementDataType  type 
)
static

Creates an OrtValue instance containing SparseTensor. This constructs a sparse tensor that makes use of user allocated buffers. It does not make copies of the user provided data and does not modify it. The lifespan of user provided buffers should eclipse the life span of the resulting OrtValue. This call constructs an instance that only contain a pointer to non-zero values. To fully populate the sparse tensor call Use<Format>Indices() API below to supply a sparse format specific indices. This API is not suitable for string data. Use CreateSparseTensor() with allocator specified so strings can be properly copied into the allocated buffer.

Parameters
infoMemory description where the user buffers reside (CPU vs GPU etc)
p_datapointer to the user supplied buffer, use nullptr for fully sparse tensors
dense_shapea would be dense shape of the tensor
values_shapenon zero values shape. Use a single 0 shape for fully sparse tensors.
typedata type
Returns
Ort::Value instance containing SparseTensor

◆ CreateSparseTensor() [3/4]

template<typename T >
static Value Ort::Value::CreateSparseTensor ( OrtAllocator allocator,
const Shape dense_shape 
)
static

This is a simple forwarding method the below CreateSparseTensor. This helps to specify data type enum in terms of C++ data type. Use CreateSparseTensor<T>

Template Parameters
Tnumeric data type only. String data enum must be specified explicitly.
Parameters
allocatorallocator to use
dense_shapea would be dense shape of the tensor
Returns
Ort::Value

◆ CreateSparseTensor() [4/4]

static Value Ort::Value::CreateSparseTensor ( OrtAllocator allocator,
const Shape dense_shape,
ONNXTensorElementDataType  type 
)
static

Creates an instance of OrtValue containing sparse tensor. The created instance has no data. The data must be supplied by on of the FillSparseTensor<Format>() methods that take both non-zero values and indices. The data will be copied into a buffer that would be allocated using the supplied allocator. Use this API to create OrtValues that contain sparse tensors with all supported data types including strings.

Parameters
allocatorallocator to use. The allocator lifespan must eclipse that of the resulting OrtValue
dense_shapea would be dense shape of the tensor
typedata type
Returns
an instance of Ort::Value

◆ CreateTensor() [1/4]

template<typename T >
static Value Ort::Value::CreateTensor ( const OrtMemoryInfo info,
T *  p_data,
size_t  p_data_element_count,
const int64_t *  shape,
size_t  shape_len 
)
static

Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.

Template Parameters
TThe numeric datatype. This API is not suitable for strings.
Parameters
infoMemory description of where the p_data buffer resides (CPU vs GPU etc).
p_dataPointer to the data buffer.
p_data_element_countThe number of elements in the data buffer.
shapePointer to the tensor shape dimensions.
shape_lenThe number of tensor shape dimensions.

◆ CreateTensor() [2/4]

static Value Ort::Value::CreateTensor ( const OrtMemoryInfo info,
void *  p_data,
size_t  p_data_byte_count,
const int64_t *  shape,
size_t  shape_len,
ONNXTensorElementDataType  type 
)
static

Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.

Parameters
infoMemory description of where the p_data buffer resides (CPU vs GPU etc).
p_dataPointer to the data buffer.
p_data_byte_countThe number of bytes in the data buffer.
shapePointer to the tensor shape dimensions.
shape_lenThe number of tensor shape dimensions.
typeThe data type.

◆ CreateTensor() [3/4]

template<typename T >
static Value Ort::Value::CreateTensor ( OrtAllocator allocator,
const int64_t *  shape,
size_t  shape_len 
)
static

Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.

Template Parameters
TThe numeric datatype. This API is not suitable for strings.
Parameters
allocatorThe allocator to use.
shapePointer to the tensor shape dimensions.
shape_lenThe number of tensor shape dimensions.

◆ CreateTensor() [4/4]

static Value Ort::Value::CreateTensor ( OrtAllocator allocator,
const int64_t *  shape,
size_t  shape_len,
ONNXTensorElementDataType  type 
)
static

Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.

Parameters
allocatorThe allocator to use.
shapePointer to the tensor shape dimensions.
shape_lenThe number of tensor shape dimensions.
typeThe data type.

◆ FillSparseTensorBlockSparse()

void Ort::Value::FillSparseTensorBlockSparse ( const OrtMemoryInfo data_mem_info,
const OrtSparseValuesParam values,
const Shape indices_shape,
const int32_t *  indices_data 
)

The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and BlockSparse indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible.

Parameters
data_mem_infospecified buffer memory description
valuesvalues buffer information
indices_shapeindices shape. use {0} for fully sparse tensors
indices_datapointer to indices data or nullptr for fully sparse tensors

◆ FillSparseTensorCoo()

void Ort::Value::FillSparseTensorCoo ( const OrtMemoryInfo data_mem_info,
const OrtSparseValuesParam values_param,
const int64_t *  indices_data,
size_t  indices_num 
)

The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and COO indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible.

Parameters
data_mem_infospecified buffer memory description
values_paramvalues buffer information.
indices_datacoo indices buffer or nullptr for fully sparse data
indices_numnumber of COO indices or 0 for fully sparse data

◆ FillSparseTensorCsr()

void Ort::Value::FillSparseTensorCsr ( const OrtMemoryInfo data_mem_info,
const OrtSparseValuesParam values,
const int64_t *  inner_indices_data,
size_t  inner_indices_num,
const int64_t *  outer_indices_data,
size_t  outer_indices_num 
)

The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API and copy the values and CSR indices into it. If data_mem_info specifies that the data is located at difference device than the allocator, a X-device copy will be performed if possible.

Parameters
data_mem_infospecified buffer memory description
valuesvalues buffer information
inner_indices_datacsr inner indices pointer or nullptr for fully sparse tensors
inner_indices_numnumber of csr inner indices or 0 for fully sparse tensors
outer_indices_datapointer to csr indices data or nullptr for fully sparse tensors
outer_indices_numnumber of csr outer indices or 0

◆ FillStringTensor()

void Ort::Value::FillStringTensor ( const char *const *  s,
size_t  s_len 
)

◆ FillStringTensorElement()

void Ort::Value::FillStringTensorElement ( const char *  s,
size_t  index 
)

◆ GetCount()

size_t Ort::Value::GetCount ( ) const

◆ GetOpaqueData()

template<typename T >
void Ort::Value::GetOpaqueData ( const char *  domain,
const char *  type_name,
T &   
) const

◆ GetSparseFormat()

OrtSparseFormat Ort::Value::GetSparseFormat ( ) const

The API returns the sparse data format this OrtValue holds in a sparse tensor. If the sparse tensor was not fully constructed, i.e. Use*() or Fill*() API were not used the value returned is ORT_SPARSE_UNDEFINED.

Returns
Format enum

◆ GetSparseTensorIndicesData()

template<typename T >
const T * Ort::Value::GetSparseTensorIndicesData ( OrtSparseIndicesFormat  indices_format,
size_t &  num_indices 
) const

The API retrieves a pointer to the internal indices buffer. The API merely performs a convenience data type casting on the return type pointer. Make sure you are requesting the right type, use GetSparseTensorIndicesTypeShapeInfo();

Template Parameters
Ttype to cast to
Parameters
indices_formatrequested indices kind
num_indicesnumber of indices entries
Returns
Pinter to the internal sparse tensor buffer containing indices. Do not free this pointer.

◆ GetSparseTensorIndicesTypeShapeInfo()

TensorTypeAndShapeInfo Ort::Value::GetSparseTensorIndicesTypeShapeInfo ( OrtSparseIndicesFormat  format) const

The API returns type and shape information for the specified indices. Each supported indices have their own enum values even if a give format has more than one kind of indices. Use GetSparseTensorIndicesData() to obtain pointer to indices buffer.

Parameters
formatenum requested
Returns
type and shape information

◆ GetSparseTensorValues()

template<typename T >
const T * Ort::Value::GetSparseTensorValues ( ) const

The API returns a pointer to an internal buffer of the sparse tensor containing non-zero values. The API merely does casting. Make sure you are requesting the right data type by calling GetSparseTensorValuesTypeAndShapeInfo() first.

Template Parameters
Tnumeric data types only. Use GetStringTensor*() to retrieve strings.
Returns
a pointer to the internal values buffer. Do not free this pointer.

◆ GetSparseTensorValuesTypeAndShapeInfo()

TensorTypeAndShapeInfo Ort::Value::GetSparseTensorValuesTypeAndShapeInfo ( ) const

The API returns type and shape information for stored non-zero values of the sparse tensor. Use GetSparseTensorValues() to obtain values buffer pointer.

Returns
TensorTypeAndShapeInfo values information

◆ GetStringTensorContent()

void Ort::Value::GetStringTensorContent ( void *  buffer,
size_t  buffer_length,
size_t *  offsets,
size_t  offsets_count 
) const

The API copies all of the UTF-8 encoded string data contained within a tensor or a sparse tensor into a supplied buffer. Use GetStringTensorDataLength() to find out the length of the buffer to allocate. The user must also allocate offsets buffer with the number of entries equal to that of the contained strings.

Strings are always assumed to be on CPU, no X-device copy.

Parameters
bufferuser allocated buffer
buffer_lengthlength in bytes of the allocated buffer
offsetsa pointer to the offsets user allocated buffer
offsets_countcount of offsets, must be equal to the number of strings contained. that can be obtained from the shape of the tensor or from GetSparseTensorValuesTypeAndShapeInfo() for sparse tensors

◆ GetStringTensorDataLength()

size_t Ort::Value::GetStringTensorDataLength ( ) const

This API returns a full length of string data contained within either a tensor or a sparse Tensor. For sparse tensor it returns a full length of stored non-empty strings (values). The API is useful for allocating necessary memory and calling GetStringTensorContent().

Returns
total length of UTF-8 encoded bytes contained. No zero terminators counted.

◆ GetStringTensorElement()

void Ort::Value::GetStringTensorElement ( size_t  buffer_length,
size_t  element_index,
void *  buffer 
) const

The API copies UTF-8 encoded bytes for the requested string element contained within a tensor or a sparse tensor into a provided buffer. Use GetStringTensorElementLength() to obtain the length of the buffer to allocate.

Parameters
buffer_length
element_index
buffer

◆ GetStringTensorElementLength()

size_t Ort::Value::GetStringTensorElementLength ( size_t  element_index) const

The API returns a byte length of UTF-8 encoded string element contained in either a tensor or a spare tensor values.

Parameters
element_index
Returns
byte length for the specified string element

◆ GetTensorData()

template<typename T >
const T * Ort::Value::GetTensorData ( ) const

◆ GetTensorMutableData()

template<typename T >
T * Ort::Value::GetTensorMutableData ( )

◆ GetTensorTypeAndShapeInfo()

TensorTypeAndShapeInfo Ort::Value::GetTensorTypeAndShapeInfo ( ) const

The API returns type information for data contained in a tensor. For sparse tensors it returns type information for contained non-zero values. It returns dense shape for sparse tensors.

Returns
TensorTypeAndShapeInfo

◆ GetTypeInfo()

TypeInfo Ort::Value::GetTypeInfo ( ) const

The API returns type information for data contained in a tensor. For sparse tensors it returns type information for contained non-zero values. It returns dense shape for sparse tensors.

Returns
TypeInfo

◆ GetValue()

Value Ort::Value::GetValue ( int  index,
OrtAllocator allocator 
) const

◆ HasValue()

bool Ort::Value::HasValue ( ) const

◆ IsSparseTensor()

bool Ort::Value::IsSparseTensor ( ) const

< Return true if OrtValue contains data and returns false if the OrtValue is a None

Returns true if the OrtValue contains a sparse tensor

Returns

◆ IsTensor()

bool Ort::Value::IsTensor ( ) const

Returns true if Value is a tensor, false for other types like map/sequence/etc.

◆ operator=()

Value & Ort::Value::operator= ( Value &&  )
default

◆ UseBlockSparseIndices()

void Ort::Value::UseBlockSparseIndices ( const Shape indices_shape,
int32_t *  indices_data 
)

Supplies BlockSparse format specific indices and marks the contained sparse tensor as being a BlockSparse format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time.

Parameters
indices_shapeindices shape or a {0} for fully sparse
indices_datauser allocated buffer with indices or nullptr for fully spare tensors

◆ UseCooIndices()

void Ort::Value::UseCooIndices ( int64_t *  indices_data,
size_t  indices_num 
)

Supplies COO format specific indices and marks the contained sparse tensor as being a COO format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time.

Parameters
indices_datapointer to the user allocated buffer with indices. Use nullptr for fully sparse tensors.
indices_numnumber of indices entries. Use 0 for fully sparse tensors

◆ UseCsrIndices()

void Ort::Value::UseCsrIndices ( int64_t *  inner_data,
size_t  inner_num,
int64_t *  outer_data,
size_t  outer_num 
)

Supplies CSR format specific indices and marks the contained sparse tensor as being a CSR format tensor. Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user allocated buffers lifespan must eclipse that of the OrtValue. The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time.

Parameters
inner_datapointer to the user allocated buffer with inner indices or nullptr for fully sparse tensors
inner_numnumber of csr inner indices or 0 for fully sparse tensors
outer_datapointer to the user allocated buffer with outer indices or nullptr for fully sparse tensors
outer_numnumber of csr outer indices or 0 for fully sparse tensors