1、github链接:https://github.com/alibaba/MNN/tree/master/tools/converter

2、教程

(1)使用教程:https://www.bookstack.cn/read/MNN-zh/tools-converter-README_CN.md

(2)参考博客:https://blog.csdn.net/qq_37643960/article/details/97028743

(3)github的项目中的readme部分也有讲解;

安装过程:

编译安装MNN动态库和Convert转换工具,命令如下:

cd /MNN/
mkdir build
cd build
cmake .. -DMNN_BUILD_CONVERTER=true
make -j4

之后build文件夹中就会出现benchmark.out和MNNConvert可执行文件;

测试benchmark.out:

./benchmark.out ../benchmark/models/  

其中10表示前向传播10次,最后结果取平均值;0表示使用CPU;(执行推理的计算设备,有效值为 0(浮点 CPU)、1(Metal)、3(浮点OpenCL)、6(OpenGL),7(Vulkan))

测试MNNConvert:

./MNNConvert -h

测试:

第一步:将pytorch模型转换为onnx模型

import torch
import torchvision dummy_input = torch.randn(10, 3, 224, 224, device='cuda')
model = torchvision.models.alexnet(pretrained=True).cuda() # Providing input and output names sets the display names for values
# within the model's graph. Setting these does not change the semantics
# of the graph; it is only for readability.
#
# The inputs to the network consist of the flat list of inputs (i.e.
# the values you would pass to the forward() method) followed by the
# flat list of parameters. You can partially specify names, i.e. provide
# a list here shorter than the number of inputs to the model, and we will
# only set that subset of names, starting from the beginning.
input_names = [ "actual_input_1" ] + [ "learned_%d" % i for i in range(16) ]
output_names = [ "output1" ] torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=True, input_names=input_names, output_names=output_names)

第二步:将onnx模型转换为mnn模型

./MNNConvert -f ONNX --modelFile alexnet.onnx --MNNModel alexnet.mnn --bizCode MNN

第三步:使用benchmark.out测试前向传播时间

./benchmark.out ./models/  

PS:在/MNN/source/shape/ShapeSqueeze.cpp 80L中:注释掉那个NanAssert(),在新版函数中已经将它注释掉了;(要不然会报reshape的error)

MNN配置的更多相关文章

  1. 配置jenkins,并把iOS包自动上传至fir.im

    安装jenkins,有两种方式 1.首先要安装 homebrew,利用homebrew来管理安装包十分方便,一条命令就可以 安装 homebrew命令 $ ruby -e "$(curl - ...

  2. 使用Notepad++开发python配置笔记

    这是我在python学习过程中,收集整理的一些notepadd++环境配置方法. 1.配置制表符 Notepad++ ->"设置"菜单->"首选项" ...

  3. solr配置中文分词器——(十二)

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqcAAAGzCAIAAACdKClDAAAgAElEQVR4nOydd5gUxdbGx5xASZKXLB

  4. Rhel5.5配置Centos yum源

    ruiy哥,抛砖引玉 当你使用rhel系统时,[大部分数据库中心及政府企业选择linux服务器时通常考虑采购的版本一般不外乎是Rhel红帽及Suse,理由你懂的EcoSystem!]你没有一个红帽网络 ...

  5. web前端的环境配置

    1.1.WEB开发的相关知识 WEB,在英语中web即表示网页的意思,它用于表示Internet主机上供外界访问的资源. Internet上供外界访问的Web资源分为: 静态web资源(如html 页 ...

  6. Ubuntu开发环境配置

    主要是: 源的更新 安装vim编辑器 远程登录xrdp相关配置 synergy symless键鼠共享配置 对新买的硬盘进行格式化和分区 vsftp环境搭建 gcc开发环境配置 qt5开发环境配置 m ...

  7. 配置android sdk 环境

    1:下载adnroid sdk安装包 官方下载地址无法打开,没有vpn,使用下面这个地址下载,地址:http://www.android-studio.org/

  8. Android Studio配置 AndroidAnnotations——Hi_博客 Android App 开发笔记

    以前用Eclicps 用习惯了现在 想学学 用Android Studio 两天的钻研终于 在我电脑上装了一个Android Studio 并完成了AndroidAnnotations 的配置. An ...

  9. react-router 组件式配置与对象式配置小区别

    1. react-router 对象式配置 和 组件式配置    组件式配置(Redirect) ----对应---- 对象式配置(onEnter钩子) IndexRedirect -----对应-- ...

随机推荐

  1. MapReduce的初识

    MapReduce是什么 HDFS:分布式存储系统 MapReduce:分布式计算系统 YARN:hadoop 的资源调度系统 Common:以上三大组件的底层支撑组件,主要提供基础工具包和 RPC ...

  2. input提示字在有焦点消失或输入改变时消失

    一:获取焦点时 提示字消失 <input type="text" name="textfield" value="这里是提示内容" o ...

  3. applyMiddleware 沉思录

    let newStore = applyMiddleware(mid1, mid2, mid3, ...)(createStore)(reducer, null); 给({ getState, dis ...

  4. First-class function

    https://en.wikipedia.org/wiki/First-class_function In computer science, a programming language is sa ...

  5. 学习:SLT_string容器

    前言:这个学了感觉没多大用,自己只需要了解就好,忘记了可以参考以下网站的示例 参考网站:https://github.com/AnkerLeng/Cpp-0-1-Resource/blob/maste ...

  6. File upload - MIME type

    Your goal is to hack this photo galery by uploading PHP code.Retrieve the validation password in the ...

  7. [Algorithm] 122. Best Time to Buy and Sell Stock II

    Previous one: https://www.cnblogs.com/Answer1215/p/11974453.html Say you have an array for which the ...

  8. clr调试扩展和DAC

    SOS.DLL.SOSEX.DLL这两个就是用来对.NET程序在Windows调试工具中起到翻译作用的调试器扩展.简单讲就是,这两个组件是.NET项目组专门开发出来用来对.NET应用程序进行方便调试用 ...

  9. Redis之eval+lua实现初步

    目录 目录 1 1. 前言 1 2. 执行方式 1 3. 执行过程 3 4. 使用原则 3 1. 前言 Redis的实现保证eval的执行是原子的,即使eval执行的lua超时,Redis也不会自动终 ...

  10. A@[G!C]%008

    A@[G!C]%008 A Simple Calculator 细节题. B Contiguous Repainting 最后只要有连续\(K\)个鸽子同色就可以构造方案,枚举+前缀和 C Tetro ...