IsDevice
TensorBuffer
函数功能
TensorBuffer的构造函数,用来创建TensorBuffer对象,根据传入的不同参数可选用不同的构造函数。
函数原型
TensorBuffer();
TensorBuffer(uint32_t size, MemoryData::MemoryType type, int32_t deviceId);
TensorBuffer(uint32_t size, int32_t deviceId);
TensorBuffer(uint32_t size);
TensorBuffer(void *ptr, uint32_t size, MemoryData::MemoryType type = MemoryData::MemoryType::MEMORY_HOST_NEW, int32_t deviceId = -1);
参数说明
| 参数名 | 输入/输出 | 说明 |
|---|---|---|
| ptr | 输入 | 内存指针。 |
| size | 输入 | 内存大小。 |
| type | 输入 | 用于构造TensorBuffer对象的内存类型。 |
| deviceId | 输入 | 用于构造TensorBuffer对象的参数,int类型数据,设备编号。 |
父主题: TensorBuffer
~TensorBuffer
函数功能
TensorBuffer类的默认析构函数。
函数原型
~TensorBuffer() {};
父主题: TensorBuffer
IsDevice
函数功能
用于判断TensorBuffer对象是否在Device侧。
函数原型
bool IsDevice() const;
返回参数说明
| 数据结构 | 说明 |
|---|---|
| bool | - true:在Device侧。 - false:不在Device侧。 |
父主题: TensorBuffer
IsHost
函数功能
用于判断TensorBuffer对象是否在Host侧。
函数原型
bool IsHost() const;
返回参数说明
| 数据结构 | 说明 |
|---|---|
| bool | - true:在Host侧。 - false:不在Host侧。 |
父主题: TensorBuffer
SetContext
函数功能
根据TensorBuffer对象中的deviceId,设置线程的Context。
函数原型
APP_ERROR SetContext() const;
返回参数说明
| 数据结构 | 说明 |
|---|---|
| APP_ERROR | 程序执行返回的错误码,请参考APP_ERROR说明。 |
父主题: TensorBuffer
TensorBufferMalloc
函数功能
用于获取TensorBuffer对象的内存。
Tensor对象在析构时会自动释放内存,因此无需通过函数释放内存。
函数原型
static APP_ERROR TensorBufferMalloc(TensorBuffer &buffer);
参数说明
| 参数名 | 输入/输出 | 说明 |
|---|---|---|
| buffer | 输入 | 用来获取对应内存的TensorBuffer数据。 |
返回参数说明
| 数据结构 | 说明 |
|---|---|
| APP_ERROR | 程序执行返回的错误码,请参考APP_ERROR说明。 |
父主题: TensorBuffer
在线提单