MNN/docs/pymnn/OpInfo.md

84 lines
1.6 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## MNN.OpInfo
```python
class OpInfo
```
OpInfo是用来描述推理过程中一个执行层的具体信息的数据类型其中包含了该层的Op类型名称计算量flops)
用法参考[runSessionWithCallBackInfo](Interpreter.html#runsessionwithcallbackinfo-session-begin-callback-end-callback)
---
### `OpInfo()`
创建一个空OpInfo
*在实际使用中创建空OpInfo没有意义仅在`runSessionWithCallBackInfo`函数中用作返回信息*
参数:
- `None`
返回OpInfo对象
返回类型:`OpInfo`
---
### `getName()`
获取该层的名称
参数:
- `None`
返回:该层的名称
返回类型:`str`
---
### `getType()`
获取该层的算子类型
参数:
- `None`
返回:该层的算子类型
返回类型:`str`
---
### `getFlops()`
获取该层的计算量
参数:
- `None`
返回:该层的计算量
返回类型:`float`
---
### `Example`
```python
import MNN
interpreter = MNN.Interpreter("mobilenet_v1.mnn")
session = interpreter.createSession()
# set input
# ...
def begin_callback(tensors, opinfo):
print('layer name = ', opinfo.getName())
print('layer op = ', opinfo.getType())
# print('layer flops = ', opinfo.getFlops())
for tensor in tensors:
print(tensor.getShape())
return True
def end_callback(tensors, opinfo):
print('layer name = ', opinfo.getName())
print('layer op = ', opinfo.getType())
# print('layer flops = ', opinfo.getFlops())
for tensor in tensors:
print(tensor.getShape())
return True
interpreter.runSessionWithCallBackInfo(session, begin_callback, end_callback)
```