Git Product home page Git Product logo

paddle2bmmodel's Introduction

1. Paddle2BMmodel使用方法

将paddle模型转化成可以在BM1684芯片上运行的fp32bmodel,或者量化需要的fp32.umodel的工具

  1. 下载inference lib

    链接: https://pan.baidu.com/s/1KIYZ1Uvr7cJH7QKwlwZSgg 密码: 8oat

    下载后拷贝到Paddle2BMmodel目录下

  2. 在比特大陆bmnnsdk2-bm1684目录,执行下面的命令(主要是设置环境变量,每开一次终端需要重新执行):

     cd scripts
    
     source envsetup_cmodel.sh
    
  3. 编译

    a) 编译转换bmodel工具p2b

    cd Paddle2BMmodel
    
    sh tools/build_p2b.sh 
    

    编译成功后生成p2b的可执行文件

    b) 编译转换umodel工具p2u

    cd Paddle2BMmodel
    
    sh tools/build_p2u.sh 
    

    编译成功后生成p2u的可执行文件

  4. 在config.txt设定模型的路径、输入shape、格式

    1)多个输入的情况,不同shape以:为分隔符, 如1,3,608,608:300,300

    2)model+params形式存放的模型,model_format设成0,__model__的形式,model_format设成1

  5. 执行 ./p2u config.txt 或./p2b config.txt就可以完成转换

2. 模型拆分(如需要)

对于一些后处理部分或其它算子不支持的模型,可以考虑将其进行拆分,模型前半部分转换成bmodel在TPU上运行,后半部分通过Paddle inference(X86)或Paddle-Lite(arm)在cpu上执行。

拆分模型使用tools/segment_paddle_model.py工具。

在工具的40行seg_node_names设置需要截断的node name(tensor的名字 ),可以通过netron工具查看,如下图。 image

设置后,运行工具,会生成first_model和second_model两个模型,完成了原模型的拆分。

paddle2bmmodel's People

Contributors

anbaolei1984 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.