Skip to content

Commit 92e2d06

Browse files
Merge pull request #126 from PanZezhong1725/update_installation_process
调整算子库编译安装流程
2 parents 765cc56 + 588f6e3 commit 92e2d06

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

.github/workflows/main.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ jobs:
3333
- name: configure xmake
3434
run: xmake f --cpu=true -cv
3535

36-
- name: Build with XMake
37-
run: xmake
38-
39-
- name: Find and Set INFINI_ROOT
40-
id: set_infini_root
36+
- name: Set INFINI_ROOT
4137
run: |
42-
export INFINI_ROOT=$GITHUB_WORKSPACE
38+
export INFINI_ROOT=$GITHUB_WORKSPACE/.infini
39+
mkdir -p $INFINI_ROOT
4340
echo "INFINI_ROOT=$INFINI_ROOT" >> $GITHUB_ENV
4441
42+
- name: Build with XMake
43+
run: xmake build && xmake install
44+
4545
- name: Run Python Tests
4646
run: |
4747
GREEN='\033[0;32m'

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ infiniopStatus_t infiniopDestroyTensorDescriptor(infiniopTensorDescriptor_t desc
7171
7272
## 一、使用说明
7373
74-
### 配置
74+
### 1. 配置
7575
7676
#### 查看当前配置
7777
@@ -99,23 +99,27 @@ xmake f --nv-gpu=true --cuda=$CUDA_HOME -cv
9999
xmake f --cambricon-mlu=true -cv
100100
```
101101

102-
### 编译
102+
#### 配置 NPU
103+
104+
````xmake
105+
xmake f --ascend-npu=true -cv
106+
````
107+
108+
### 2. 编译安装
103109

104110
```xmake
105-
xmake
111+
xmake build && xmake install
106112
```
107113

108-
### 将编译好的算子库添加至环境变量 `INFINI_ROOT`
114+
### 3. 设置环境变量
109115

110-
```bash
111-
export INFINI_ROOT=[PATH_TO_LIBRARY]
112-
```
116+
按输出提示设置 `INFINI_ROOT``LD_LIBRARY_PATH` 环境变量。
113117

114-
### 运行算子测试
118+
### 4. 运行算子测试
115119

116120
```bash
117121
cd operatorspy/tests
118-
python operator_name.py
122+
python operator_name.py [--cpu | --cuda | --cambricon | --ascend]
119123
```
120124

121125
## 二、开发说明

xmake.lua

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ if has_config("cambricon-mlu") then
125125
table.insert(target:objectfiles(), objectfile)
126126
end)
127127

128-
rule_end()
128+
rule_end()
129129

130130

131131
target("cambricon-mlu")
@@ -179,7 +179,7 @@ if has_config("ascend-npu") then
179179
os.rm(builddir.. "/libascend_kernels.a")
180180

181181
end)
182-
rule_end()
182+
rule_end()
183183

184184
target("ascend-npu")
185185
-- Other configs
@@ -226,9 +226,6 @@ target("infiniop")
226226
get_config("mode")
227227
)
228228

229-
os.exec("mkdir -p $(projectdir)/lib/")
230-
os.exec("cp " ..builddir.. "/libinfiniop.so $(projectdir)/lib/")
231-
os.exec("cp -r $(projectdir)/include $(projectdir)/lib/")
232229
-- Define color codes
233230
local GREEN = '\27[0;32m'
234231
local YELLOW = '\27[1;33m'
@@ -244,23 +241,35 @@ target("infiniop")
244241

245242
on_install(function (target)
246243
print("Installing libraries...")
247-
if os.getenv("INFINI_ROOT") == nil then
244+
245+
local GREEN = '\27[0;32m'
246+
local YELLOW = '\27[1;33m'
247+
local NC = '\27[0m' -- No Color
248+
249+
local infini_dir = os.getenv("INFINI_ROOT")
250+
if infini_dir == nil then
248251
print(YELLOW .. "INFINI_ROOT not set, installation path default to ~/.infini".. NC)
249252
print(YELLOW .. "It is recommended to set INFINI_ROOT as an environment variable." .. NC)
250-
os.setenv("INFINI_ROOT", os.getenv("HOME") .. "/.infini")
253+
infini_dir = os.getenv("HOME") .. "/.infini"
251254
end
252-
local infini_dir = os.getenv("INFINI_ROOT")
253255

254256
if os.isdir(infini_dir) then
255257
print("INFINI_ROOT already exists, duplicated contents will be overwritten.")
256258
else
257259
os.mkdir(infini_dir)
258260
end
259-
os.exec("cp -r " .. "$(projectdir)/lib " .. infini_dir)
260261

261-
local GREEN = '\27[0;32m'
262-
local YELLOW = '\27[1;33m'
263-
local NC = '\27[0m' -- No Color
262+
local builddir = string.format(
263+
"%s/build/%s/%s/%s",
264+
os.projectdir(),
265+
get_config("plat"),
266+
get_config("arch"),
267+
get_config("mode")
268+
)
269+
os.exec("mkdir -p " .. infini_dir .. "/lib")
270+
os.exec("cp " ..builddir.. "/libinfiniop.so " .. infini_dir .. "/lib/")
271+
os.exec("cp -r $(projectdir)/include " .. infini_dir .. "/include")
272+
264273
os.exec("echo -e '" .. GREEN .. "Installation completed successfully at " .. infini_dir .. NC .. "'")
265274
os.exec("echo -e '" .. YELLOW .. "To set the environment variables, you can run the following command:" .. NC .. "'")
266275
os.exec("echo -e '" .. YELLOW .. "export INFINI_ROOT=" .. infini_dir .. NC .. "'")

0 commit comments

Comments
 (0)