mindspore::lite¶
Context¶
#include <context.h>
Context类用于保存执行中的环境变量。
构造函数和析构函数¶
公有属性¶
device_list_¶
device_list_
DeviceContextVector 类型, 元素为 DeviceContext 的vector.
现在支持CPU、GPU和NPU。如果设置了GPU设备环境变量并且设备支持GPU,优先使用GPU设备,否则优先使用CPU设备。如果设置了NPU设备环境变量并且设备支持NPU,优先使用NPU设备,否则优先使用CPU设备。
StringsToMSTensor¶
int StringsToMSTensor(const std::vector<std::string> &inputs, tensor::MSTensor *tensor)
全局方法,用于将字符串存入MSTensor。
返回值
STATUS,STATUS在errorcode.h中定义。
MSTensorToStrings¶
std::vector<std::string> MSTensorToStrings(const tensor::MSTensor *tensor)
全局方法,用于从MSTensor获取字符串。
返回值
字符串的vector。
CpuDeviceInfo¶
#include <context.h>
CpuDeviceInfo类,配置CPU的环境变量。
TrainModel¶
#include <model.h>
继承于结构体Model,用于导入或导出训练模型。
公有成员函数¶
Import¶
static TrainModel *Import(const char *model_buf, size_t size);
导入模型。
参数
model_buf
: 指向存储读入MindSpore模型缓冲区的常量字符型指针。size
: 缓冲区大小。
返回值
返回一个指向MindSpore Lite训练模型(TrainModel)的指针。
ExportBuf¶
char* ExportBuf(char *buf, size_t *len) const;
导出模型缓冲区。
参数
buf
: 指向模型导出的目标缓冲区的指针,如果指针为空则自动分配一块内存。len
: 指向预分配缓冲区大小的指针。
返回值
返回一个指向存储导出模型缓冲区的字符指针。