ModelParallelRunner
import com.mindspore.config.RunnerConfig;
ModelParallelRunner定义了MindSpore Lite并发推理。
公有成员函数
| function | 云侧推理是否支持 | 端侧推理是否支持 | 
|---|---|---|
| √ | ✕ | |
| √ | ✕ | |
| √ | ✕ | |
| √ | ✕ | |
| √ | ✕ | |
| √ | ✕ | |
| √ | ✕ | 
getModelParallelRunnerPtr
public long getModelParallelRunnerPtr()
获取底层并发推理类指针。
- 返回值 - 底层并发推理类指针。 
init
public boolean init(String modelPath, RunnerConfig runnerConfig)
根据路径加载模型,生成一个或者多个模型,并将所有模型编译至可在Device上运行的状态。该接口支持传入ms模型(converter_lite工具导出)和mindir模型(MindSpore导出或converter_lite工具导出),但对ms模型的支持,将在未来的迭代中删除,推荐使用mindir模型进行推理。当使用ms模型进行推理时,请保持模型的后缀名为.ms,否则无法识别。
- 参数 - modelPath: 模型文件路径。
- runnerConfig: 一个RunnerConfig结构体。定义了并发推理模型的配置参数。
 
- 返回值 - 是否初始化成功。 
public boolean init(String modelPath)
根据路径加载模型,生成一个或者多个模型,并将所有模型编译至可在Device上运行的状态。该接口支持传入ms模型(converter_lite工具导出)和mindir模型(MindSpore导出或converter_lite工具导出),但对ms模型的支持,将在未来的迭代中删除,推荐使用mindir模型进行推理。当使用ms模型进行推理时,请保持模型的后缀名为.ms,否则无法识别。
- 参数 - modelPath: 模型文件路径。
 
- 返回值 - 是否初始化成功。 
predict
public boolean predict(List<MSTensor> inputs, List<MSTensor> outputs)
并发推理模型。
- 参数 - inputs: 模型输入。
- outputs: 模型输出。
 
- 返回值 - 推理是否成功。 
getInputs
public List<MSTensor> getInputs()
获取模型所有输入张量。
- 返回值 - 模型的输入张量列表。 
getOutputs
public List<MSTensor> getOutputs()
获取模型所有输出张量。
- 返回值 - 模型的输出张量列表。 
free
public void free()
释放并发推理类的内存。