Giter Site home page Giter Site logo

ai_hpc's Introduction

AI_HPC

AI高性能计算相关

Code

pytorch_int8_resnet.py

运行结果

截屏2023-12-08 12 51 33

maxSumDiv3.cu

实现功能

对数组nums,求能被3整除最大子序列和

实现思路

maxSumDivThreeCPU()为CPU实现版本,dp每次根据上一个位置的mod0、1、2的最大和更新当前位置mod0、1、2的最大子序列和。

GPU版本实现思路:分为findMaxSumInSubArrays()和reduceModMaxsum()前后两部分: (为了方便实现,这里假设数组总长度能被(numBlocks*blockSize)整除)

  1. findMaxSumInSubArrays():首先把整个数组等分给每个block(假设1024个block),每个thread处理totalLength//(numBlocksblockSize)个data;每个thread的处理过程和CPU上的dp过程一致,for循环求得这部分数的mod0、1、2的最大子序列和;于是通过findMaxSumInSubArrays()得到了numBlocksblockSize组数的mod0、1、2的最大子序列和

  2. reduceModMaxsum():在每个block内采用reduce归并的方式更新这blockSize组数的mod0、1、2的最大子序列和 通过如下的方式对mod3=0,1,2的最大子序列和进行归并: 考虑两个数组a,b, 它们mod3=0,1,2的最大子序列和分别为(sumMod0_a,sumMod1_a,sumMod2_a),(sumMod0_b,sumMod1_b,sumMod2_b) 则a,b合并的数组c, mod3=0,1,2的最大子序列和为:(特别地,没有对应的mod和时记为负无穷)

sumMod0_c = max(sumMod0_a+sumMod0_b, sumMod1_a+sumMod2_b, sumMod2_a+sumMod1_b)
sumMod1_c = max(sumMod0_a+sumMod1_b, sumMod1_a+sumMod0_b, sumMod2_a+sumMod2_b)
sumMod2_c = max(sumMod0_a+sumMod2_b, sumMod1_a+sumMod1_b, sumMod2_a+sumMod0_b)

在modMaxsum数组的第0/1/2个位置即为每个block对应数组mod 3 = 0/1/2的最大子序列和 最后在CPU上执行一次循环次数为numBlocks的最大子序列和合并,得到全局的最大子序列和

Quantization

pytorch Quantization Introduction

pytorch Quantization Tutorial

各种量化工具的差异

int8量化相关论文:

Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference

Integer Quantization for Deep Learning Inference: Principles and Empirical Evaluation

算子融合相关论文:

Learning to Fuse

AI系统资料:

https://github.com/chenzomi12/DeepLearningSystem

ai_hpc's People

Contributors

zhou-yijie avatar

Watchers

 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.