onnx-mlir
|
Go to the source code of this file.
Typedefs | |
typedef struct OMTensor | OMTensor |
Functions | |
OMTensor * | omTensorCreate (void *data_ptr, int64_t *shape, int64_t rank, OM_DATA_TYPE dtype) |
Create a OMTensor with specified data pointer, shape, rank and element type. More... | |
OMTensor * | omTensorCreateWithOwnership (void *data_ptr, int64_t *shape, int64_t rank, OM_DATA_TYPE dtype, int owning) |
Create an OMTensor with specified data pointer, shape, rank and element type, manually setting data ptr ownership. More... | |
OMTensor * | omTensorCreateEmpty (int64_t *shape, int64_t rank, OM_DATA_TYPE dtype) |
void | omTensorDestroy (OMTensor *tensor) |
Destroy the OMTensor struct. More... | |
void * | omTensorGetDataPtr (OMTensor *tensor) |
OMTensor data pointer getter. More... | |
int64_t * | omTensorGetShape (OMTensor *tensor) |
OMTensor data shape getter. More... | |
void | omTensorSetShape (OMTensor *tensor, int64_t *shape) |
OMTensor data shape setter. More... | |
int64_t * | omTensorGetStrides (OMTensor *tensor) |
OMTensor data strides getter. More... | |
void | omTensorSetStrides (OMTensor *tensor, int64_t *stride) |
OMTensor data strides setter. More... | |
void | omTensorSetStridesWithPyArrayStrides (OMTensor *tensor, int64_t *stridesInBytes) |
OMTensor data strides setter with stride values from PyArray strides. More... | |
OM_DATA_TYPE | omTensorGetDataType (OMTensor *tensor) |
OMTensor data type getter. More... | |
void | omTensorSetDataType (OMTensor *tensor, OM_DATA_TYPE dataType) |
OMTensor data type setter. More... | |
int64_t | omTensorGetBufferSize (OMTensor *tensor) |
OMTensor data buffer size getter. More... | |
int | omTensorGetRank (OMTensor *tensor) |
OMTensor rank getter. More... | |
int64_t | omTensorGetNumElems (OMTensor *tensor) |
OMTensor number of elements getter. More... | |
int | omTensorGetOwning (OMTensor *tensor) |
OMTensor owning flag getter. More... | |
OMTensor* omTensorCreate | ( | void * | data_ptr, |
int64_t * | shape, | ||
int64_t | rank, | ||
OM_DATA_TYPE | dtype | ||
) |
Create a OMTensor with specified data pointer, shape, rank and element type.
The call will not create a copy of the data. By default, caller is responsible for managing the memory this pointer refers to. Namely, the OMTensor is not the owner of the data. To indicate OMTensor's ownership of data, use omTensorCreateWithOwnership
. Ownership determines what happens with the OMTensor is destroyed. With ownership of the data, the destruction of the OMTensor will also free the data.
data_ptr | pointer to tensor data. By default, caller is responsible for managing the memory this pointer refers to. |
shape | list of integers indicating the tensor shape. |
rank | tensor rank. |
dtype | tensor element data type. |
OMTensor* omTensorCreateEmpty | ( | int64_t * | shape, |
int64_t | rank, | ||
OM_DATA_TYPE | dtype | ||
) |
Create an OMTensor with the specified shape, rank and element type, allocate uninitialized data for the specified shape. This function is intentionally left out from the header because it is only used by the wrapper code we emit around inference function that converts MemRefs to OMTensors for user convenience.
The OMTensor created using this constructor owns the underlying memory space allocated to the content of the tensor.
shape | list of integers indicating the tensor shape. |
rank | tensor rank. |
dtype | tensor element data type. |
OMTensor* omTensorCreateWithOwnership | ( | void * | data_ptr, |
int64_t * | shape, | ||
int64_t | rank, | ||
OM_DATA_TYPE | dtype, | ||
int | owning | ||
) |
Create an OMTensor with specified data pointer, shape, rank and element type, manually setting data ptr ownership.
Using this constructor, users can specify whether OMTensor owns the data, which subsequently determines whether the memory space underlying the data will be freed or not when OMTensor gets destroyed.
data_ptr | pointer to tensor data. |
shape | list of integers indicating the tensor shape. |
rank | tensor rank. |
dtype | tensor element data type. |
owning | whether OMTensor owns the data, if set to true, OMTensor will release the data_ptr upon destruction. |
void omTensorDestroy | ( | OMTensor * | tensor | ) |
Destroy the OMTensor struct.
If OMTensor does not own the data, destroying the omTensor does not free up the memory occupied by the tensor content. If OMTensor owns the data, this function will free up the memory space underlying the tensor as well. The documentation of OMTensor constructors clarifies the ownership semantics.
tensor | pointer to the OMTensor |
int64_t omTensorGetBufferSize | ( | OMTensor * | tensor | ) |
OMTensor data buffer size getter.
tensor | pointer to the OMTensor |
void* omTensorGetDataPtr | ( | OMTensor * | tensor | ) |
OMTensor data pointer getter.
tensor | pointer to the OMTensor |
OM_DATA_TYPE omTensorGetDataType | ( | OMTensor * | tensor | ) |
OMTensor data type getter.
tensor | pointer to the OMTensor |
int64_t omTensorGetNumElems | ( | OMTensor * | tensor | ) |
OMTensor number of elements getter.
tensor,pointer | to the OMTensor |
int omTensorGetOwning | ( | OMTensor * | tensor | ) |
OMTensor owning flag getter.
int omTensorGetRank | ( | OMTensor * | tensor | ) |
OMTensor rank getter.
tensor,pointer | to the OMTensor |
int64_t* omTensorGetShape | ( | OMTensor * | tensor | ) |
OMTensor data shape getter.
The data shape is returned as a pointer pointing to an array of n 64-bit integers where n is the rank of the tensor.
The shape array is returned without copying, so caller should not free the returned pointer.
tensor | pointer to the OMTensor |
int64_t* omTensorGetStrides | ( | OMTensor * | tensor | ) |
OMTensor data strides getter.
The data strides are returned as a pointer pointing to an array of n 64-bit integers where n is the rank of the tensor.
The strides array is returned without copying, so caller should not free the returned pointer.
tensor | pointer to the OMTensor |
void omTensorSetDataType | ( | OMTensor * | tensor, |
OM_DATA_TYPE | dataType | ||
) |
OMTensor data type setter.
tensor | pointer to the OMTensor |
dataType | ONNX data type to be set |
Set the ONNX data type of the data buffer elements.
void omTensorSetShape | ( | OMTensor * | tensor, |
int64_t * | shape | ||
) |
OMTensor data shape setter.
n int64 elements are copied from the shape array to indicate the shape of the tensor, where n is the rank of the tensor.
The shape array is copied without being freed, so caller is expected to manage the shape array oneself.
tensor | pointer to the OMTensor |
shape | data shape array to be set |
Set the data shape array of the OMTensor to the values in the input array.
void omTensorSetStrides | ( | OMTensor * | tensor, |
int64_t * | stride | ||
) |
OMTensor data strides setter.
n int64 elements are copied from the strides array to indicate the per-dimension stride of the tensor, where n is the rank of the tensor.
The strides array is copied without being freed, so caller is expected to manage the strides array oneself.
tensor | pointer to the OMTensor |
strides | tensor strides array to be set. |
Set the data strides array of the OMTensor to the values in the input array.
void omTensorSetStridesWithPyArrayStrides | ( | OMTensor * | tensor, |
int64_t * | stridesInBytes | ||
) |
OMTensor data strides setter with stride values from PyArray strides.
Note that PyArray stride values are in bytes, while OMTensor stride values in elements. Thus, PyArray stride values will be divided by datatype size before passing to OMTensor stride values.
n int64 elements are copied from the strides array to indicate the per-dimension stride of the tensor, where n is the rank of the tensor.
The strides array is copied without being freed, so caller is expected to manage the strides array oneself.
tensor | pointer to the OMTensor |
strides | tensor strides array to be set. |
Set the data strides array of the OMTensor to the values in the input array.