当前位置:网站首页>模型的推理速度
模型的推理速度
2022-07-27 05:13:00 【Mr_health】
1. 模型大小的四种描述

2. 计算量、访存量与推理速度的关系
2.1 计算密度
从上面可以看出计算量和访存量都能影响模型的推理速度,那么进一步定义计算密度为计算量除以访存量,如下:

计算密度用于反映一个程序是计算更为密集,还是访存更为密集。
- 计算密集型程序:Compute bound
- 访存密集型程序:Memory bound
2.2 Roofline 模型
一种用于评估程序在硬件上能达到的性能上界的数学模型。
横轴表示计算密度,在2.1我们讲述每一个模型都有一个计算密度,也就是说横轴表示的是模型。纵轴表示的是计算速度。
这个数学模型表示,在这块硬件上跑某一个模型(给出一个计算密度)所能达到的最佳的计算速度。

可以看出来这个是一个分段函数:
- 对于访存型密集程序:计算速度 = 计算密度 × 带宽,即与硬件的带宽有非常大的关系。
- 对于计算型密集程序,计算速度 = 峰值计算速度,即与硬件的算力(峰值计算速度)有很大关系。
2.3 推理速度
在2.2的部分给出了计算速度的计算方式,知道了计算速度就可以计算出来推理速度,如下

对于访存密集的计算公式是:
计算量/计算速度 = 计算量 / (计算密度 * 带宽) = 计算量/(计算量 * 带宽 /访存量) = 访存量/带宽
这里我们没有像上面那样区分程序,而是变为算子,因为一个模型中可能既有访存密集型的算子,也有计算密集的算子,因此推理速度也没有像上面的公式一样严格区分,而是比较复杂的。
- 访存密集型算子:Concat、Eltwise Add、ReLU、MaxPooling……
- 计算密集型算子:Conv、DeConv、FC、MatMul、LSTM……
边栏推荐
- Jenkins build image automatic deployment
- 【高并发】面试官
- GBASE 8C——SQL参考6 sql语法(11)
- Global evidence of expressed sentimental alterations during the covid-19 pandemics
- 2.简单回归问题
- 数字图像处理——第三章 灰度变换与空间滤波
- Gbase 8C - SQL reference 6 SQL syntax (3)
- 2021中大厂php+go面试题(2)
- 3.分类问题---手写数字识别初体验
- Docker deploys the stand-alone version of redis - modify the redis password and persistence method
猜你喜欢

How can seektiger go against the cold air in the market?

Seektiger's okaleido has a big move. Will the STI of ecological pass break out?

Graph node deployment

我想不通,MySQL 为什么使用 B+ 树来作索引?

13.逻辑回归

数字图像处理——第三章 灰度变换与空间滤波

DDD领域驱动设计笔记

Day 6. Analysis of the energy transmission process of network public opinion in major medical injury events * -- Taking the "Wei Zexi incident" as an example

1. Introduction to pytorch

Seektiger will launch STI fusion mining function to obtain Oka pass
随机推荐
If the interviewer asks you about JVM, the extra answer of "escape analysis" technology will give you extra points
常用adb命令汇总 性能优化
Seven enabling schemes of m-dao help Dao ecology move towards mode and standardization
舆情&传染病时空分析文献阅读笔记
万字解析MySQL索引原理——InnoDB索引结构与读取
The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market
golang怎么给空结构体赋值
1.PyTorch简介
Emoji Emoji for text emotion analysis -improving sentimental analysis accuracy with Emoji embedding
Docker deploys the stand-alone version of redis - modify the redis password and persistence method
Rk3288 board HDMI displays logo images of uboot and kernel
MySQL如何执行查询语句
RK3288板卡HDMI显示uboot和kernel的logo图片
【好文种草】根域名的知识 - 阮一峰的网络日志
数字图像处理——第九章 形态学图像处理
什么是okr,和kpi的区别在哪里
新冠时空分析——Global evidence of expressed sentiment alterations during the COVID-19 pandemic
Day14. Using interpretable machine learning method to distinguish intestinal tuberculosis and Crohn's disease
golang中slice切片使用的误区
vscode打造golang开发环境以及golang的debug单元测试