MNN::Interpreter类 参考

`#include <Interpreter.hpp>`

## Public 成员函数

| ~Interpreter ()
Session * | createSession (const ScheduleConfig &config)
| create session with schedule config. created session will be managed in net. 更多...
Session * | createMultiPathSession (const std::vector< ScheduleConfig > &configs)
| create multi-path session with schedule configs. created session will be managed in net. 更多...
bool | releaseSession (Session *session)
| release session. 更多...
void | resizeSession (Session *session)
| call this function to get tensors ready. output tensor buffer (host or deviceId) should be retrieved after resize of any input tensor. 更多...
void | releaseModel ()
| call this function if don't need resize or create session any more, it will save a few memory that equal to the size of model buffer 更多...
ErrorCode | runSession (Session *session) const
| run session. 更多...
ErrorCode | runSessionWithCallBack (const Session *session, const TensorCallBack &before, const TensorCallBack &end, bool sync=false) const
ErrorCode | runSessionWithCallBackInfo (const Session *session, const TensorCallBackWithInfo &before, const TensorCallBackWithInfo &end, bool sync=false) const
Tensor * | getSessionInput (const Session *session, const char *name)
| get input tensor for given name. 更多...
Tensor * | getSessionOutput (const Session *session, const char *name)
| get output tensor for given name. 更多...
const std::map< std::string, Tensor * > & | getSessionOutputAll (const Session *session) const
| get all input tensors. 更多...
const std::map< std::string, Tensor * > & | getSessionInputAll (const Session *session) const
| get all output tensors. 更多...
void | resizeTensor (Tensor *tensor, const std::vector< int > &dims)
| resize given tensor. 更多...
const Backend * | getBackend (const Session *session, const Tensor *tensor) const
| get backend used to create given tensor. 更多...
const char * | bizCode () const
| get business code (model identifier). 更多...

## 静态 Public 成员函数

static Interpreter * | createFromFile (const char *file)
| create net from file. 更多...
static Interpreter * | createFromBuffer (const void *buffer, size_t size)
| create net from buffer. 更多...

## 详细描述

net data holder. multiple sessions could share same net.

## 构造及析构函数说明

## ~Interpreter()

MNN::Interpreter::~Interpreter | ( |  | ) |

## 成员函数说明

## bizCode()

const char* MNN::Interpreter::bizCode | ( |  | ) | const

get business code (model identifier).

返回
  business code.

## createFromBuffer()

static Interpreter* MNN::Interpreter::createFromBuffer | ( | const void * | buffer,
|  | size_t | size
| ) |  |

static

create net from buffer.

参数

  buffer | given data buffer.
  size | size of data buffer.

返回
  created net if success, NULL otherwise.

## createFromFile()

static Interpreter* MNN::Interpreter::createFromFile | ( | const char * | file | ) |

static

create net from file.

参数

  file | given file.

返回
  created net if success, NULL otherwise.

## createMultiPathSession()

Session* MNN::Interpreter::createMultiPathSession | ( | const std::vector< ScheduleConfig > & | configs | ) |

create multi-path session with schedule configs. created session will be managed in net.

参数

  configs | session schedule configs.

返回
  created session if success, NULL otherwise.

## createSession()

Session* MNN::Interpreter::createSession | ( | const ScheduleConfig & | config | ) |

create session with schedule config. created session will be managed in net.

参数

  config | session schedule config.

返回
  created session if success, NULL otherwise.

## getBackend()

const Backend* MNN::Interpreter::getBackend | ( | const Session * | session,
|  | const Tensor * | tensor
| ) |  | const

get backend used to create given tensor.

参数

  session | given session.
  tensor | given tensor.

返回
  backend used to create given tensor, may be NULL.

## getSessionInput()

Tensor* MNN::Interpreter::getSessionInput | ( | const Session * | session,
|  | const char * | name
| ) |  |

get input tensor for given name.

参数

  session | given session.
  name | given name. if NULL, return first input.

返回
  tensor if found, NULL otherwise.

## getSessionInputAll()

const std::map<std::string, Tensor*>& MNN::Interpreter::getSessionInputAll | ( | const Session * | session | ) | const

get all output tensors.

参数

  session | given session.

返回
  all output tensors mapped with name.

## getSessionOutput()

Tensor* MNN::Interpreter::getSessionOutput | ( | const Session * | session,
|  | const char * | name
| ) |  |

get output tensor for given name.

参数

  session | given session.
  name | given name. if NULL, return first output.

返回
  tensor if found, NULL otherwise.

## getSessionOutputAll()

const std::map<std::string, Tensor*>& MNN::Interpreter::getSessionOutputAll | ( | const Session * | session | ) | const

get all input tensors.

参数

  session | given session.

返回
  all input tensors mapped with name.

## releaseModel()

void MNN::Interpreter::releaseModel | ( |  | ) |

call this function if don't need resize or create session any more, it will save a few memory that equal to the size of model buffer

## releaseSession()

bool MNN::Interpreter::releaseSession | ( | Session * | session | ) |

release session.

参数

  session | given session.

返回
  true if given session is held by net and is freed.

## resizeSession()

void MNN::Interpreter::resizeSession | ( | Session * | session | ) |

call this function to get tensors ready. output tensor buffer (host or deviceId) should be retrieved after resize of any input tensor.

参数

  session | given session.

## resizeTensor()

void MNN::Interpreter::resizeTensor | ( | Tensor * | tensor,
|  | const std::vector< int > & | dims
| ) |  |

resize given tensor.

参数

  tensor | given tensor.
  dims | new dims. at most 6 dims.

## runSession()

ErrorCode MNN::Interpreter::runSession | ( | Session * | session | ) | const

run session.

参数

  session | given session.

返回
  result of running.

## runSessionWithCallBack()

ErrorCode MNN::Interpreter::runSessionWithCallBack | ( | const Session * | session,
|  | const TensorCallBack & | before,
|  | const TensorCallBack & | end,
|  | bool | sync = `false`
| ) |  | const

## runSessionWithCallBackInfo()

ErrorCode MNN::Interpreter::runSessionWithCallBackInfo | ( | const Session * | session,
|  | const TensorCallBackWithInfo & | before,
|  | const TensorCallBackWithInfo & | end,
|  | bool | sync = `false`
| ) |  | const

该类的文档由以下文件生成:

- include/Interpreter.hpp