Giter Club home page Giter Club logo

vgg16-cuda's Introduction

VGG 模型(CUDA实现)


  • 文件说明
    • model/:模型参数预处理
    • paras.json:模型各层类型,参数。
    • vgg16_main.cu:模型主函数,负责读取数据,初始化,调用推理函数,对比正确性
    • model.hpp:模型定义,初始化,推理
    • layers.cuh:定义具体层(kernel function)操作
    • utils.h:一些帮助函数
    • json.hpp:c++ 读取json库, 原仓库链接
    • Makefile:
      • make: 编译
      • make clean: 清除输出文件
  • 代码架构:
    • 通过传如传入模型参数以及权重参文件路径,构造VGG16类,初始化模型。
    • 调用类函数VGG16::inference(float*,float*)进行推理,传出输出。
  • 优化:
    • 并行方式:
      • 卷积层: 并行粒度为每个thread计算每张特征图上的一个点,每个block计算一张特征图
      • 池化层: 并行粒度为每个thread计算每张输出特征图上的一个点
    • ,每个block计算输出的一个二维矩阵
      • 全连接层: 并行粒度为每个thread计算每张输出矩阵上的一个点
    • 共享内存:
      • 在卷积中,每个卷积核对应一张特征图,并且被一个block计算,所以说可以先将卷积核加载到共享内存中,然后在每个block中thread对其进行取用。
    • 寄存器优化:
      • 在每个函数当中使用寄存器加快访问速度
    • 集成relu到各个层当中
    • 减小线程数量: 在每个线程进行多个计算,减小overhead。
  • 步骤
    • 模型解析,
    • 模型读取
    • 模型编写-cuda
    • 测试正确性
    • 优化
  • 在服务器上执行:
    $ cd /home/group3/workspace/VGG
    $ make
    $ ./model.o
  • 代码效果:
    • 最终版本:
      res1
    • 无shared_memory
      res3

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.