@@ -26,9 +26,17 @@ InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功
2626
2727API 定义以及使用方式详见 [ ` InfiniCore文档 ` ] ( https://github.com/InfiniTensor/InfiniCore-Documentation ) 。
2828
29+ ## 项目依赖
30+
31+ - [ Xmake] ( https://xmake.io/ ) :跨平台自动构建工具,用于编译 InfiniCore 项目。
32+ - [ gcc-11] ( https://gcc.gnu.org/ ) 以上或者 [ clang-16] ( https://clang.llvm.org/ ) :基础编译器,需要支持 C++ 17 标准。
33+ - [ Python>=3.10] ( https://www.python.org/ )
34+ - [ PyTorch] ( https://pytorch.org/ ) :可选,用于对比测试。
35+ - 各个硬件平台的工具包:请参考各厂商官方文档(如英伟达平台需要安装 CUDA Toolkit)。
36+
2937## 配置和使用
3038
31- ### 子模块
39+ ### 一、克隆项目
3240
3341由于仓库中含有子模块,所以在克隆时请添加 ` --recursive ` 或 ` --recurse-submodules ` ,如:
3442
@@ -42,7 +50,27 @@ git clone --recursive https://github.com/InfiniTensor/InfiniCore.git
4250git submodule update --init --recursive
4351```
4452
45- ### 一键安装
53+ 如果你需要在本地开发九齿算子(即需要对九齿算子库进行修改),推荐单独克隆[ 九齿算子库] ( https://github.com/InfiniTensor/ntops ) ,并从本地安装:
54+
55+ ``` shell
56+ git clone https://github.com/InfiniTensor/ntops.git
57+ cd ntops
58+ pip install -e .
59+ ```
60+
61+ ### 二、编译安装
62+
63+ InfiniCore 项目主要包括:
64+
65+ 1 . 底层 C 库(InfiniOP/InfiniRT/InfiniCCL):[ ` 一键安装 ` ] ( #一键安装底层库 ) |[ ` 手动安装 ` ] ( #手动安装底层库 ) ;
66+ 2 . InfiniCore C++ 库:[ ` 安装指令 ` ] ( #2-安装-c-库 )
67+ 3 . InfiniCore Python 包(依赖[ 九齿算子库] ( https://github.com/InfiniTensor/ntops ) ):[ ` 安装指令 ` ] ( #3-安装-python-包 )
68+
69+ 三者需要按照顺序进行编译安装。
70+
71+ #### 1. 安装底层库
72+
73+ ##### 一键安装底层库
4674
4775在 ` script/ ` 目录中提供了 ` install.py ` 安装脚本。使用方式如下:
4876
@@ -69,11 +97,17 @@ python scripts/install.py [XMAKE_CONFIG_FLAGS]
6997| ` --ninetoothed=[y\|n] ` | 是否编译九齿实现 | n
7098| ` --ccl=[y\|n] ` | 是否编译 InfiniCCL 通信库接口实现 | n
7199
72- ### 手动安装
100+ ##### 手动安装底层库
73101
741020 . 生成九齿算子(可选)
75103
76- 参见[ 使用九齿] ( #使用九齿 ) 章节。
104+ - 克隆并安装[ 九齿算子库] ( https://github.com/InfiniTensor/ntops ) 。
105+
106+ - 在 ` InfiniCore ` 文件夹下运行以下命令 AOT 编译库中的九齿算子:
107+
108+ ``` shell
109+ PYTHONPATH=${PYTHONPATH} :src python scripts/build_ntops.py
110+ ```
77111
781121. 项目配置
79113
@@ -118,91 +152,60 @@ python scripts/install.py [XMAKE_CONFIG_FLAGS]
118152
119153 按输出提示设置 ` INFINI_ROOT` 和 ` LD_LIBRARY_PATH` 环境变量。
120154
121- # ## 运行测试
122-
123- # ### 运行Python算子测试
155+ # ### 2. 安装 C++ 库
124156
125157` ` ` shell
126- python test/infiniop/[operator].py [--cpu | --nvidia | --cambricon | --ascend]
127- ` ` `
128-
129- # ### 一键运行所有Python算子测试
130-
131- ` ` ` shell
132- python scripts/python_test.py [--cpu | --nvidia | --cambricon | --ascend]
158+ xmake build _infinicore
159+ xmake install _infinicore
133160` ` `
134161
135- # ### 算子测试框架
136-
137- 详见 ` test/infiniop-test` 目录
138-
139- # ### 通信库(InfiniCCL)测试
140-
141- 编译(需要先安装InfiniCCL):
162+ # ### 3. 安装 Python 包
142163
143164` ` ` shell
144- xmake build infiniccl-test
165+ pip install .
145166` ` `
146167
147- 在英伟达平台运行测试(会自动使用所有可见的卡):
168+ 或
148169
149170` ` ` shell
150- infiniccl-test --nvidia
171+ pip install . -e
151172` ` `
152173
153- # ## ` infinicore` Python 包
174+ 注:开发时建议加入 ` -e ` 选项(即 ` pip install -e . ` ),这样对 ` python/ infinicore` 做的更改将会实时得到反映,同时对 C++ 层所做的修改也只需要运行 ` xmake build _infinicore && xmake install _infinicore ` 便可以生效。
154175
155- # ### 构建
176+ # ## 三、运行测试
156177
157- 1. 进行[手动安装](# 手动安装)。
158- 2. 构建与安装内部依赖库 ` _infinicore` :
178+ # ### 运行 InfiniCore Python算子接口测试
159179
160- ` ` ` shell
161- xmake build _infinicore
180+ ` ` ` bash
181+ python test/infinicore/run.py --nvidia --verbose --bench
162182` ` `
163183
164- # ### 安装
184+ 使用 -h 查看更多参数。
165185
166- 1. 安装 ` _infinicore ` :
186+ # ### 运行 InfiniOP 算子测试
167187
168188` ` ` shell
169- xmake install _infinicore
170- ` ` `
171-
172- 2. 安装 ` infinicore` :
173-
174- ` ` ` shell
175- pip install .
189+ # 测试单算子
190+ python test/infiniop/[operator].py [--cpu | --nvidia | --cambricon | --ascend]
191+ # 测试全部算子
192+ python scripts/python_test.py [--cpu | --nvidia | --cambricon | --ascend]
176193` ` `
177194
178- 注:开发时建议加入 ` -e` 选项(即 ` pip install -e .` ),这样对 ` python/infinicore` 做的更改将会实时得到反映,同时对 C++ 层所做的修改也只需要运行 ` xmake build _infinicore && xmake install _infinicore` 便可以生效。
179-
180- # ## 使用九齿
181-
182- [九齿](https://github.com/InfiniTensor/ninetoothed)是一门基于 Triton 但提供更高层抽象的领域特定语言(DSL)。使用九齿可以降低算子的开发门槛,并且提高开发效率。
183-
184- InfiniCore 目前已经可以接入使用九齿实现的算子,但是这部分实现的编译是默认关闭的。如果选择编译库中的九齿实现,需要使用 ` --ninetoothed=y` ,并在运行一键安装脚本前完成以下准备工作:
195+ # ### 通信库(InfiniCCL)测试
185196
186- 1. 安装九齿与[九齿算子库](https://github.com/InfiniTensor/ntops) :
197+ 编译(需要先安装底层库中的 InfiniCCL 库) :
187198
188199` ` ` shell
189- git clone https://github.com/InfiniTensor/ntops.git
190- cd ntops
191- pip install -e .
200+ xmake build infiniccl-test
192201` ` `
193202
194- 注:安装 ` ntops` 时,` ninetoothed` 会被当成依赖也一并安装进来。
195-
196- 2. 在 ` InfiniCore` 文件夹下运行以下命令 AOT 编译库中的九齿算子:
203+ 在英伟达平台运行测试(会自动使用所有可见的卡):
197204
198205` ` ` shell
199- PYTHONPATH= ${PYTHONPATH} :src python scripts/build_ntops.py
206+ infiniccl-test --nvidia
200207` ` `
201208
202- 注:如果对九齿相关文件有修改,需要重新构建 InfiniCore 时,也需要同时运行以上命令进行重新生成。
203-
204- 3. 按照上面的指引进行[一键安装](# 一键安装)或者[手动安装](#手动安装)。
205-
206209# # 如何开源贡献
207210
208211见 [` InfiniCore开发者手册` ](DEV.md)。
0 commit comments