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. 利用form.submit提交表单导出文件到客户端浏览器, 提示下载!

    本来是想利用ajax提交json数据到服务端, 让服务端生成一个excel文件并提示客户端浏览器下载的. 但是搞了很久发现ajax方式是无法触发浏览器弹出文件下载的. 网上很多的方案都是说利用form ...

  2. 《剑指Offer》-006 - Java版快速幂 -解决n的m次方的问题

    #### 如题 (总结要点) 原文链接 : 1.主题 package blank; /** * 类的详细说明 给定一个double类型的浮点数base和int类型的整数exponent.求base的e ...

  3. 通过PHP自带的$_SERVER判断 自动识别移动设备

    因为站点需要,手机端和PC端分离,所以通过PHP自带的$_SERVER判断 自动识别移动设备 代码如下: <?php $agent = $_SERVER['HTTP_USER_AGENT']; ...

  4. 【Javascript】数组之二

    Array 对象方法 方法 描述 concat() 连接两个或更多的数组,并返回结果. copyWithin() 从数组的指定位置拷贝元素到数组的另一个指定位置中. entries() 返回数组的可迭 ...

  5. PureComponent & shouldComponentUpdate

    Called to determine whether the change in props and state should trigger a re-render. Component alwa ...

  6. LeetCode 1197. Minimum Knight Moves

    原题链接在这里:https://leetcode.com/problems/minimum-knight-moves/ 题目: In an infinite chess board with coor ...

  7. base64文件隐写脚本

    base64文件隐写脚本 base64 可以在文件中隐藏信息,记录一下提取脚本 ''' base64文件隐写脚本 import re import base64 b64chars = 'ABCDEFG ...

  8. 014_matlab读取ecxel(直接导入)

    视频教程:https://v.qq.com/x/page/c3039b5htwx.html 资料下载:https://download.csdn.net/download/xiaoguoge11/12 ...

  9. vue基于页面中按钮权限控制

    main.js // 权限 /** 权限指令,对按钮权限的控制 **/ Vue.directive('allow', { bind: function(el, binding) { // 通过当前按钮 ...

  10. Python爬虫 | xpath的安装

    错误信息:程序包无效.详细信息:“Cannot load extension with file or directory name . Filenames starting with "& ...