File tree 6 files changed +60
-91
lines changed
6 files changed +60
-91
lines changed Original file line number Diff line number Diff line change 10
10
# add these directories to sys.path here. If the directory is relative to the
11
11
# documentation root, use os.path.abspath to make it absolute, like shown here.
12
12
import sys
13
+ import os
13
14
from pathlib import Path
14
15
from docutils .nodes import literal_block
15
16
from pygments .lexers import ClassNotFound , find_lexer_class_by_name
19
20
ROOT = Path (__file__ ).resolve ().parents [1 ]
20
21
sys .path .extend ([str (ROOT / 'src' ), str (ROOT / "doc/_ext" )])
21
22
23
+ # Define the canonical URL if you are using a custom domain on Read the Docs
24
+ html_baseurl = os .environ .get ("READTHEDOCS_CANONICAL_URL" , "https://xinetzone.github.io/tvm-book" )
25
+
26
+ # Tell Jinja2 templates the build is running on Read the Docs
27
+ if os .environ .get ("READTHEDOCS" , "" ) == "True" :
28
+ if "html_context" not in globals ():
29
+ html_context = {}
30
+ html_context ["READTHEDOCS" ] = True
31
+
22
32
import tvm_book
23
33
# 国际化
24
34
# https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/i18n.html
70
80
"sphinx_automodapi.smart_resolver" ,
71
81
'autoapi.extension' ,
72
82
"sphinxcontrib.icon" ,
83
+ "sphinx_build_compatibility.extension" ,
73
84
]
74
85
75
86
autodoc_default_options = {
189
200
# Define the json_url for our version switcher.
190
201
json_url = 'https://xinetzone.github.io/tvm-book/_static/switcher.json'
191
202
version = release
192
- html_baseurl = "https://xinetzone.github.io/tvm-book"
193
203
194
204
switcher_version = f'v{ version } '
195
205
if "dev" in version :
Original file line number Diff line number Diff line change 67
67
"cell_type" : " markdown" ,
68
68
"metadata" : {},
69
69
"source" : [
70
- " {icon}`fa fa-folder-open` `caffe_demo/` 文件夹下存在如下内容:\n " ,
70
+ " {icon}`fa-solid fa-folder-open` `caffe_demo/` 文件夹下存在如下内容:\n " ,
71
71
" \n " ,
72
- " - {icon}`fa fa-file` `test.caffemodel` 存储 caffe 模型参数的初始化模型\n " ,
73
- " - {icon}`fa fa-file` `test.prototxt` 存储 caffe 模型结构\n " ,
74
- " - {icon}`fa fa-file` `config.toml` 存储 caffe 模型配置信息\n " ,
72
+ " - {icon}`fa-solid fa-file` `test.caffemodel` 存储 caffe 模型参数的初始化模型\n " ,
73
+ " - {icon}`fa-solid fa-file` `test.prototxt` 存储 caffe 模型结构\n " ,
74
+ " - {icon}`fa-solid fa-file` `config.toml` 存储 caffe 模型配置信息\n " ,
75
75
" ```{include} models/caffe_demo/config.toml\n " ,
76
76
" :code: toml\n " ,
77
77
" ```"
Original file line number Diff line number Diff line change 67
67
"cell_type" : " markdown" ,
68
68
"metadata" : {},
69
69
"source" : [
70
- " {icon}`fa fa-folder-open` `pytorch_demo/` 文件夹下存在如下内容:\n " ,
70
+ " {icon}`fa-solid fa-folder-open` `pytorch_demo/` 文件夹下存在如下内容:\n " ,
71
71
" \n " ,
72
- " - {icon}`fa fa-file` `save.py` 存储 PyTorch 模型为 `resnet18.pth`\n " ,
72
+ " - {icon}`fa-solid fa-file` `save.py` 存储 PyTorch 模型为 `resnet18.pth`\n " ,
73
73
" ```{include} models/pytorch_demo/save.py\n " ,
74
74
" :code: python\n " ,
75
75
" ```\n " ,
76
- " - {icon}`fa fa-file` `resnet18.pth` 存储 PyTorch 模型结构与参数\n " ,
77
- " - {icon}`fa fa-file` `config.toml` 存储 PyTorch 模型配置信息\n " ,
76
+ " - {icon}`fa-solid fa-file` `resnet18.pth` 存储 PyTorch 模型结构与参数\n " ,
77
+ " - {icon}`fa-solid fa-file` `config.toml` 存储 PyTorch 模型配置信息\n " ,
78
78
" ```{include} models/pytorch_demo/config.toml\n " ,
79
79
" :code: toml\n " ,
80
80
" ```"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # MSC 简介
2
+
3
+ 参考:[ 【我与TVM二三事 后篇(1)】MSC简介] ( https://zhuanlan.zhihu.com/p/680638069 )
4
+
5
+ [ MSC] ( https://discuss.tvm.apache.org/t/rfc-unity-msc-introduction-to-multi-system-compiler/15251 ) (Multi-System Compiler,多系统编译器)旨在将 ` tvm ` 与其他机器学习框架(例如 ` torch ` 、` tensorflow ` 、` tensorrt ` 等)和系统(例如训练系统、部署系统等)连接起来。借助 MSC,可以开发模型压缩方法,如高级 PTQ(训练后量化)、QAT(量化感知训练)、修剪训练、稀疏训练、知识蒸馏等。此外,MSC 将模型编译过程管理为流水线,因此可以轻松地基于 MSC 构建模型编译服务(Saas)和编译工具链(tool-chain)。
6
+
7
+ MSC 被用作 NIO.Inc 的 AI 引擎的重要部分。介绍可以在 TVMConf 2023(TVM @ NIO) 找到。
8
+
9
+ 这个开源版本的 MSC 与 NIO.Inc 中的MSC有以下不同:
10
+
11
+ - NIO中的运行时优化和量化不会被包含在这个开源版本中。
12
+ - 这个版本使用relax和relay来构建MSCGraph,而在 NIO 中只使用 relay。
13
+ - 这个版本专注于自动压缩和训练相关的优化方法,而 NIO 的 AI 引擎更注重运行时加速和与自动驾驶相关的量化。
14
+
15
+ ## 动机
16
+
17
+ 随着 TVM 的优化,模型性能和内存管理已经达到了一个相对较高的水平。为了将模型性能提升到更高的层次,同时确保准确性,需要新的方法。模型压缩技术被证明在提高模型性能的同时减少内存消耗方面是有用的。常规的压缩方法,如修剪和量化,需要算法、软件和硬件系统的合作,这使得压缩策略难以开发和维护,因为信息格式因系统而异,压缩策略也因案例而异。为了与不同的系统协作并开发作为模型无关工具的压缩算法,需要用于保存、传递和转换信息的架构。
18
+
19
+ ## 参考级解释
20
+
21
+ MSC 中的编译流水线如下所示:
22
+
23
+ ![ ] ( images/msc.jpeg )
24
+
25
+ ### 核心概念:
26
+
27
+ MSCGraph:MSC 的核心 IR(中间表示)。MSCGraph 是 Relax.Function/Relay.Function 的 DAG(有向无环图)格式。
28
+
29
+ - MSC codegen:为框架生成模型构建代码(包括控制 MSCTool 的包装器)。
30
+ - RuntimeManager:管理运行时、MSCGraphs 和 MSCTools 的抽象模块。
31
+ - MSCTools:决定压缩策略并控制压缩过程的工具。此外,还为调试添加了一些额外的工具到MSCTools中。
32
+ - Config:MSC 使用配置来控制编译过程。这使得编译过程易于被记录和重放。
33
+
34
+ ### 编译过程:
35
+
36
+ 编译过程包含两个主要阶段:优化(optimize)和最终化(finalize)。optimize and finalize
37
+
38
+ 优化阶段用于通过压缩来优化模型。这个阶段可能会使用训练框架,并且消耗大量的时间和资源(例如自动压缩、知识蒸馏和训练)。
39
+
40
+ 最终化阶段用于在所需环境中构建模型。这个阶段从优化后的 ` relax ` 模块(检查点)开始,并在目标环境中构建该模块,不进行任何优化。这个阶段可以在所需环境中进行处理,而不会消耗大量时间和资源。
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ doc = [
52
52
" autodocsumm" ,
53
53
" sphinx-autoapi" ,
54
54
" lxml" ,
55
- " sphinx-icon"
55
+ " sphinx-icon" ,
56
56
]
57
57
58
58
onnx = [
You can’t perform that action at this time.
0 commit comments