TVM: An Automated End-to-End Optimizing Compiler for Deep Learning

TVM can process graph-level and operator-level optimization.

graph-level optimization

As for the graph-level optimization, it can do operator fusion, constant folding, static memory pre-allocation, and data transformate pass.

operator fusion

Now I want emphasis operator fusion, It split the operator into 4 type:

  • injective (one on one map, e.g., add)
  • reduction
  • complex out fusable(can fuse element-wise op to output)
  • opaque(can't be fused, e.g., sort)

TVM will fuse as much as possible.

These optimization methods are very common.

Operator-level Optimization

TVM seperate schedule and compute. So it can detribute different devices. There are 3 schedule primitives in TVM, Special Memory Scope, Tensorizaiton, Latency Hiding.

  • Special Memory Scope, to utilize maxmium the shaped memory in GPU.
  • Tensorization, spliting a bigger data into micro-data to fully utiize the vectorization.
  • Latency Hiding. Overlaping the computation and transition. On CPU, it is achieving by using multi-threading or hardward prefetching. GPU relys on repid context switching of many wraps of threads.

Automating Optimization

How to find the optimal parameter is very important. It proposed a ML-based cost model, which is a gradient tree boosting model based on XGboost, to predict these prameters by giving the loop pragram in the kernel, which include the memory access count, and the resue ratio of each memory buffer, as well as one-hot encoding of loop annotation such as "vectorize", "unroll" and "parallel". As shown in the following graph, the collected data can be train the model again. So the TVM matainer will updated this model periodicly.

Consequently, TVM lowers the threshold for writing a relavely high-performance kernel. I think there are 2 points deserved us to learn more, which are the schedule primitive and the prediction model.

相关推荐
月光船幽幽2 分钟前
门控函数SHS阈值与调制机制解析
人工智能·python·算法
秦先生在广东6 分钟前
Agency-Agents:用结构化「职业操作系统」替代临时 Prompt 的 AI 角色仓库
人工智能
王烁鑫17 分钟前
从 0 到 1 做实时语音 Agent:先解决“会不会误操作”,再谈自主行动
人工智能
lucas_AI18 分钟前
Muse Glimmer 30B:Meta 难得给的真开源,强在哪、虚在哪
人工智能·算法
字节跳动数据库18 分钟前
火山引擎 RDS MySQL 向量索引:把高性能向量检索带到 MySQL 上
人工智能·后端·mysql
一心只读圣贤书19 分钟前
AI 驱动前端测试实战:从需求文档到 Playwright 自动化用例
前端·人工智能
小白的后端世界20 分钟前
LangChain 模型初始化参数详解:从基础配置到企业级实践
java·人工智能·langchain
jimidou21 分钟前
第 0 篇:Agent 世界观——先搞懂 LLM、Context、Tool 与 Agent 到底是什么
人工智能
过期的秋刀鱼!24 分钟前
带替换的采样
人工智能·python·算法·决策树·机器学习
Python私教26 分钟前
AI Agent 可观测性不只是日志:一套可回放的多步执行链
人工智能·后端·python