335 Star 1.5K Fork 864

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
lite_session.md 3.72 KB
一键复制 编辑 原始数据 按行查看 历史
宦晓玲 提交于 2023-07-21 15:10 . modify the md links in 1.2

LiteSession

View Source On Gitee

import com.mindspore.lite.LiteSession;

LiteSession defines session in MindSpore Lite for compiling Model and forwarding model.

Public Member Functions

function
boolean init(MSConfig config)
void bindThread(boolean if_bind)
boolean compileGraph(Model model)
boolean runGraph()
List<MSTensor> getInputs()
MSTensor getInputsByTensorName(String tensorName)
List<MSTensor> getOutputsByNodeName(String nodeName)
Map<String, MSTensor> getOutputMapByTensor()
List<String> getOutputTensorNames()
MSTensor getOutputByTensorName(String tensorName)
boolean resize(List<MSTensor> inputs, int[][] dims
void free()

init

public boolean init(MSConfig config)

Initialize LiteSession.

  • Parameters

    • MSConfig: MSConfig class.
  • Returns

    Whether the initialization is successful.

bindThread

public void bindThread(boolean if_bind)

Attempt to bind or unbind threads in the thread pool to or from the specified cpu core.

  • Parameters

    • if_bind: Define whether to bind or unbind threads.

compileGraph

public boolean compileGraph(Model model)

Compile MindSpore Lite model.

  • Parameters

    • Model: Define the model to be compiled.
  • Returns

    Whether the compilation is successful.

runGraph

public boolean runGraph()

Run the session for inference.

  • Returns

    Whether the inference is successful.

getInputs

public List<MSTensor> getInputs()

Get the MSTensors input of MindSpore Lite model.

  • Returns

    The vector of MindSpore Lite MSTensor.

getInputsByTensorName

public MSTensor getInputsByTensorName(String tensorName)

Get the MSTensors input of MindSpore Lite model by the node name.

  • Parameters

    • tensorName: Define the tensor name.
  • Returns

    MindSpore Lite MSTensor.

getOutputsByNodeName

public List<MSTensor> getOutputsByNodeName(String nodeName)

Get the MSTensors output of MindSpore Lite model by the node name.

  • Parameters

    • nodeName: Define the node name.
  • Returns

    The vector of MindSpore Lite MSTensor.

getOutputMapByTensor

public Map<String, MSTensor> getOutputMapByTensor()

Get the MSTensors output of the MindSpore Lite model associated with the tensor name.

  • Returns

    The map of output tensor name and MindSpore Lite MSTensor.

getOutputTensorNames

public List<String> getOutputTensorNames()

Get the name of output tensors of the model compiled by this session.

  • Returns

    The vector of string as output tensor names in order.

getOutputByTensorName

public MSTensor getOutputByTensorName(String tensorName)

Get the MSTensors output of MindSpore Lite model by the tensor name.

  • Parameters

    • tensorName: Define the tensor name.
  • Returns

    Pointer of MindSpore Lite MSTensor.

resize

public boolean resize(List<MSTensor> inputs, int[][] dims)

Resize inputs shape.

  • Parameters

    • inputs: Model inputs.
    • dims: Define the new inputs shape.
  • Returns

    Whether the resize is successful.

free

public void free()

Free LiteSession.

1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r1.2

搜索帮助