16 #ifndef ONNX_MLIR_OMTENSOR_H
17 #define ONNX_MLIR_OMTENSOR_H
30 #if defined(__APPLE__) || defined(__MVS__)
36 #include "onnx-mlir/Compiler/OMCompilerMacros.h"
37 #include "onnx-mlir/Runtime/OnnxDataType.h"
93 void *data_ptr,
const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype);
124 const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype, int64_t owning);
144 const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype);
199 OMTensor *tensor,
const int64_t *shape);
231 OMTensor *tensor,
const int64_t *stride);
252 OMTensor *tensor,
const int64_t *stridesInBytes);
279 OMTensor *tensor, OM_DATA_TYPE dataType);
282 static inline int64_t getDataTypeSize(OM_DATA_TYPE dataType) {
283 return OM_DATA_TYPE_SIZE[dataType];
332 const char *msg,
const OMTensor *tensor);
OM_EXTERNAL_VISIBILITY void omTensorSetStrides(OMTensor *tensor, const int64_t *stride)
OMTensor data strides setter.
OM_EXTERNAL_VISIBILITY void omTensorSetDataType(OMTensor *tensor, OM_DATA_TYPE dataType)
OMTensor data type setter.
OM_EXTERNAL_VISIBILITY const int64_t * omTensorGetStrides(const OMTensor *tensor)
OMTensor data strides getter.
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreate(void *data_ptr, const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype)
Create a OMTensor with specified data pointer, shape, rank and element type.
OM_EXTERNAL_VISIBILITY void omTensorSetStridesWithPyArrayStrides(OMTensor *tensor, const int64_t *stridesInBytes)
OMTensor data strides setter with stride values from PyArray strides.
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreateWithOwnership(void *data_ptr, const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype, int64_t owning)
Create an OMTensor with specified data pointer, shape, rank and element type, manually setting data p...
struct OMTensor OMTensor
Definition: OMTensor.h:57
OM_EXTERNAL_VISIBILITY int64_t omTensorGetNumElems(const OMTensor *tensor)
OMTensor number of elements getter.
OM_EXTERNAL_VISIBILITY int64_t omTensorGetRank(const OMTensor *tensor)
OMTensor rank getter.
OM_EXTERNAL_VISIBILITY void omTensorSetShape(OMTensor *tensor, const int64_t *shape)
OMTensor data shape setter.
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreateEmpty(const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype)
OM_EXTERNAL_VISIBILITY const int64_t * omTensorGetShape(const OMTensor *tensor)
OMTensor data shape getter.
OM_EXTERNAL_VISIBILITY void omTensorPrint(const char *msg, const OMTensor *tensor)
OM_EXTERNAL_VISIBILITY int64_t omTensorGetOwning(const OMTensor *tensor)
OMTensor owning flag getter.
OM_EXTERNAL_VISIBILITY void * omTensorGetDataPtr(const OMTensor *tensor)
OMTensor data pointer getter.
OM_EXTERNAL_VISIBILITY int64_t omTensorGetBufferSize(const OMTensor *tensor)
OMTensor numerical data buffer size getter.
OM_EXTERNAL_VISIBILITY OM_DATA_TYPE omTensorGetDataType(const OMTensor *tensor)
OMTensor data type getter.
OM_EXTERNAL_VISIBILITY void omTensorDestroy(OMTensor *tensor)
Destroy the OMTensor struct.
OM_EXTERNAL_VISIBILITY void omTensorSetOwning(OMTensor *tensor, int64_t owning)
OMTensor owning flag setter.