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);
214 OMTensor *tensor,
const int64_t *shape);
246 OMTensor *tensor,
const int64_t *stride);
267 OMTensor *tensor,
const int64_t *stridesInBytes);
294 OMTensor *tensor, OM_DATA_TYPE dataType);
297static inline int64_t getDataTypeSize(OM_DATA_TYPE dataType) {
298 return OM_DATA_TYPE_SIZE[dataType];
347 const char *msg,
const OMTensor *tensor);
OM_EXTERNAL_VISIBILITY void omTensorSetStrides(OMTensor *tensor, const int64_t *stride)
OMTensor 数据步长设置器。
OM_EXTERNAL_VISIBILITY const int64_t * omTensorGetStrides(const OMTensor *tensor)
OMTensor 数据步长获取器。
OM_EXTERNAL_VISIBILITY void omTensorSetDataType(OMTensor *tensor, OM_DATA_TYPE dataType)
OMTensor 数据类型设置器。
OM_EXTERNAL_VISIBILITY void * omTensorGetDataPtr(const OMTensor *tensor)
OMTensor 数据指针获取器。
OM_EXTERNAL_VISIBILITY void omTensorSetStridesWithPyArrayStrides(OMTensor *tensor, const int64_t *stridesInBytes)
使用 PyArray 步长值设置 OMTensor 数据步长。
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreateEmpty(const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype)
struct OMTensor OMTensor
定义于 OMTensor.h:57
OM_EXTERNAL_VISIBILITY void * omTensorGetAllocatedPtr(const OMTensor *tensor)
OMTensor 已分配数据指针获取器。
OM_EXTERNAL_VISIBILITY int64_t omTensorGetNumElems(const OMTensor *tensor)
OMTensor 元素数量获取器。
OM_EXTERNAL_VISIBILITY int64_t omTensorGetRank(const OMTensor *tensor)
OMTensor 秩获取器。
OM_EXTERNAL_VISIBILITY void omTensorSetShape(OMTensor *tensor, const int64_t *shape)
OMTensor 数据形状设置器。
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreateWithOwnership(void *data_ptr, const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype, int64_t owning)
创建一个具有指定数据指针、形状、秩和元素类型的 OMTensor,手动设置数据指针...
OM_EXTERNAL_VISIBILITY void omTensorPrint(const char *msg, const OMTensor *tensor)
OM_EXTERNAL_VISIBILITY OMTensor * omTensorCreate(void *data_ptr, const int64_t *shape, int64_t rank, OM_DATA_TYPE dtype)
创建一个具有指定数据指针、形状、秩和元素类型的 OMTensor。
OM_EXTERNAL_VISIBILITY int64_t omTensorGetOwning(const OMTensor *tensor)
OMTensor 所有权标志获取器。
OM_EXTERNAL_VISIBILITY const int64_t * omTensorGetShape(const OMTensor *tensor)
OMTensor 数据形状获取器。
OM_EXTERNAL_VISIBILITY int64_t omTensorGetBufferSize(const OMTensor *tensor)
OMTensor 数值数据缓冲区大小获取器。
OM_EXTERNAL_VISIBILITY OM_DATA_TYPE omTensorGetDataType(const OMTensor *tensor)
OMTensor 数据类型获取器。
OM_EXTERNAL_VISIBILITY void omTensorDestroy(OMTensor *tensor)
销毁 OMTensor 结构体。
OM_EXTERNAL_VISIBILITY void omTensorSetOwning(OMTensor *tensor, int64_t owning)
OMTensor 所有权标志设置器。