Skip to content

Commit 7b26372

Browse files
author
liuxinwei
committed
更新
1 parent 6d1a7ae commit 7b26372

File tree

6 files changed

+60
-91
lines changed

6 files changed

+60
-91
lines changed

doc/conf.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
import sys
13+
import os
1314
from pathlib import Path
1415
from docutils.nodes import literal_block
1516
from pygments.lexers import ClassNotFound, find_lexer_class_by_name
@@ -19,6 +20,15 @@
1920
ROOT = Path(__file__).resolve().parents[1]
2021
sys.path.extend([str(ROOT/'src'), str(ROOT/"doc/_ext")])
2122

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+
2232
import tvm_book
2333
# 国际化
2434
# https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/i18n.html
@@ -70,6 +80,7 @@
7080
"sphinx_automodapi.smart_resolver",
7181
'autoapi.extension',
7282
"sphinxcontrib.icon",
83+
"sphinx_build_compatibility.extension",
7384
]
7485

7586
autodoc_default_options = {
@@ -189,7 +200,6 @@
189200
# Define the json_url for our version switcher.
190201
json_url = 'https://xinetzone.github.io/tvm-book/_static/switcher.json'
191202
version = release
192-
html_baseurl = "https://xinetzone.github.io/tvm-book"
193203

194204
switcher_version = f'v{version}'
195205
if "dev" in version:

doc/topics/ai/caffe-model.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
"cell_type": "markdown",
6868
"metadata": {},
6969
"source": [
70-
"{icon}`fa fa-folder-open` `caffe_demo/` 文件夹下存在如下内容:\n",
70+
"{icon}`fa-solid fa-folder-open` `caffe_demo/` 文件夹下存在如下内容:\n",
7171
"\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",
7575
" ```{include} models/caffe_demo/config.toml\n",
7676
" :code: toml\n",
7777
" ```"

doc/topics/ai/pytorch-model.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@
6767
"cell_type": "markdown",
6868
"metadata": {},
6969
"source": [
70-
"{icon}`fa fa-folder-open` `pytorch_demo/` 文件夹下存在如下内容:\n",
70+
"{icon}`fa-solid fa-folder-open` `pytorch_demo/` 文件夹下存在如下内容:\n",
7171
"\n",
72-
"- {icon}`fa fa-file` `save.py` 存储 PyTorch 模型为 `resnet18.pth`\n",
72+
"- {icon}`fa-solid fa-file` `save.py` 存储 PyTorch 模型为 `resnet18.pth`\n",
7373
" ```{include} models/pytorch_demo/save.py\n",
7474
" :code: python\n",
7575
" ```\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",
7878
" ```{include} models/pytorch_demo/config.toml\n",
7979
" :code: toml\n",
8080
" ```"

doc/tutorials/msc/intro.ipynb

-81
This file was deleted.

doc/tutorials/msc/intro.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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` 模块(检查点)开始,并在目标环境中构建该模块,不进行任何优化。这个阶段可以在所需环境中进行处理,而不会消耗大量时间和资源。

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ doc = [
5252
"autodocsumm",
5353
"sphinx-autoapi",
5454
"lxml",
55-
"sphinx-icon"
55+
"sphinx-icon",
5656
]
5757

5858
onnx = [

0 commit comments

Comments
 (0)