Unverified Commit dc52ac84 authored by PanZezhong1725's avatar PanZezhong1725 Committed by GitHub
Browse files

Merge pull request #138 from InfiniTensor/issue/134

issue/134 添加一键安装脚本
parents e5bda616 e4cfb9f6
...@@ -20,35 +20,46 @@ jobs: ...@@ -20,35 +20,46 @@ jobs:
- name: checkout code - name: checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: install black - name: Check Format
run: pip install black run: |
pip install black
- name: check format python3 scripts/format.py --path src --check
run: python3 scripts/format.py --path src --check
- name: install xmake - name: install xmake
uses: xmake-io/github-action-setup-xmake@v1 uses: xmake-io/github-action-setup-xmake@v1
with: with:
xmake-version: latest xmake-version: latest
- name: configure xmake - name: Build & Install (Linux)
run: xmake f --omp=y -cv if: matrix.os == 'ubuntu-latest'
run: bash scripts/install.sh . --omp=y
- name: Build & Install (Windows)
if: matrix.os == 'windows-latest'
run: scripts/install.bat . --omp=y
- name: build with xmake - name: install python packages
run: xmake build run: |
pip install numpy
- name: install to INFINI_ROOT pip install torch
if: matrix.os != 'windows-latest'
run: xmake install
- name: build infiniop-test - name: Python Test (Linux)
if: matrix.os != 'windows-latest' if: matrix.os == 'ubuntu-latest'
run: xmake build infiniop-test run: |
export LD_LIBRARY_PATH=$HOME/.infini/lib:$LD_LIBRARY_PATH
python test/infiniop/gemm.py --cpu
python test/infiniop/rms_norm.py --cpu
python test/infiniop/causal_softmax.py --cpu
python test/infiniop/swiglu.py --cpu
python test/infiniop/random_sample.py --cpu
- name: python test - name: Python Test (Windows)
if: matrix.os != 'windows-latest' if: matrix.os == 'windows-latest'
run: | run: |
pip install torch set PATH=$env:USERPROFILE\.infini\bin;$env:PATH
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/gemm.py --cpu python test\infiniop\gemm.py --cpu
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/rms_norm.py --cpu python test\infiniop\rms_norm.py --cpu
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/random_sample.py --cpu python test\infiniop\causal_softmax.py --cpu
python test\infiniop\swiglu.py --cpu
python test\infiniop\random_sample.py --cpu
...@@ -15,6 +15,22 @@ InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功 ...@@ -15,6 +15,22 @@ InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功
## 配置和使用 ## 配置和使用
### 一键安装
`script/` 目录中分别提供了 `install.bat` windows安装脚本和 `install.sh` linux安装脚本。使用方式如下:
```shell
cd InfiniCore
# Windows
.\scripts\install.bat . --nv-gpu=true
# Linux
source ./scripts/install.sh . --nv-gpu=true
```
### 手动安装
1. 项目配置 1. 项目配置
- 查看当前配置 - 查看当前配置
...@@ -55,12 +71,18 @@ InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功 ...@@ -55,12 +71,18 @@ InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功
按输出提示设置 `INFINI_ROOT``LD_LIBRARY_PATH` 环境变量。 按输出提示设置 `INFINI_ROOT``LD_LIBRARY_PATH` 环境变量。
4. 运行算子测试 ### 运行测试
#### 运行Python算子测试
```shell ```shell
python test/infiniop/[operator].py [--cpu | --nvidia | --cambricon | --ascend] python test/infiniop/[operator].py [--cpu | --nvidia | --cambricon | --ascend]
``` ```
#### 算子测试框架
详见 `test/infiniop-test` 目录
## 开发指南 ## 开发指南
### 代码格式化 ### 代码格式化
......
...@@ -65,10 +65,10 @@ typedef enum { ...@@ -65,10 +65,10 @@ typedef enum {
INFINI_DTYPE_F16 = 12, INFINI_DTYPE_F16 = 12,
INFINI_DTYPE_F32 = 13, INFINI_DTYPE_F32 = 13,
INFINI_DTYPE_F64 = 14, INFINI_DTYPE_F64 = 14,
INFINI_DTYPE_C8 = 15, INFINI_DTYPE_C16 = 15,
INFINI_DTYPE_C16 = 16, INFINI_DTYPE_C32 = 16,
INFINI_DTYPE_C32 = 17, INFINI_DTYPE_C64 = 17,
INFINI_DTYPE_C64 = 18, INFINI_DTYPE_C128 = 18,
INFINI_DTYPE_BF16 = 19, INFINI_DTYPE_BF16 = 19,
} infiniDtype_t; } infiniDtype_t;
......
@echo off
setlocal
:: Check if project path is provided
if "%~0"=="" (
echo Usage: install.bat PROJECT_PATH [XMAKE_CONFIG_FLAGS]
exit /b 1
)
:: Set INFINI_ROOT
set "INFINI_ROOT=%USERPROFILE%\.infini"
:: Check if INFINI_ROOT\bin is already in PATH, if not, add it
echo %PATH% | findstr /I /C:"%INFINI_ROOT%\bin" >nul
if %errorlevel% neq 0 set "PATH=%INFINI_ROOT%\bin;%PATH%"
:: Convert relative path to absolute path
for %%I in ("%~1") do set ABS_PATH=%%~fI
:: Change to the project directory
cd %ABS_PATH%
:: Build xmake config flags
set XMAKE_FLAGS=
set i=0
for %%A in (%*) do (
if !i! gtr set XMAKE_FLAGS=!XMAKE_FLAGS! %%A
set /a i+=1
)
:: Start installation
xmake clean -a
if %errorlevel% neq 0 exit /b %errorlevel%
xmake f %XMAKE_FLAGS% -cv
if %errorlevel% neq 0 exit /b %errorlevel%
xmake
if %errorlevel% neq 0 exit /b %errorlevel%
xmake install
if %errorlevel% neq 0 exit /b %errorlevel%
xmake build infiniop-test
if %errorlevel% neq 0 exit /b %errorlevel%
xmake install infiniop-test
if %errorlevel% neq 0 exit /b %errorlevel%
#!/bin/bash
set -e # Exit on error
# Check if project path is provided
if [ -z "$1" ]; then
echo "Usage: source deploy.sh PROJECT_PATH [XMAKE_CONFIG_FLAGS]"
exit 1
fi
# Set INFINI_ROOT
export INFINI_ROOT="$HOME/.infini"
# Check if INFINI_ROOT/bin is already in PATH, if not, add it
case ":$PATH:" in
*":$INFINI_ROOT/bin:"*) ;; # Already in PATH, do nothing
*) export PATH="$INFINI_ROOT/bin:$PATH" ;; # Add to PATH
esac
# Check if INFINI_ROOT/lib is already in LD_LIBRARY_PATH, if not, add it
case ":$LD_LIBRARY_PATH:" in
*":$INFINI_ROOT/lib:"*) ;; # Already in LD_LIBRARY_PATH, do nothing
*) export LD_LIBRARY_PATH="$INFINI_ROOT/lib:$LD_LIBRARY_PATH" ;; # Add to LD_LIBRARY_PATH
esac
# Change to project directory
cd "$1"
# Shift first argument (project path) and pass the rest to xmake
shift
xmake clean -a
xmake f "$@" -cv
xmake
xmake install
xmake build infiniop-test
xmake install infiniop-test
...@@ -36,13 +36,13 @@ inline size_t infiniSizeOf(infiniDtype_t dtype) { ...@@ -36,13 +36,13 @@ inline size_t infiniSizeOf(infiniDtype_t dtype) {
return 4; return 4;
case INFINI_DTYPE_F64: case INFINI_DTYPE_F64:
return 8; return 8;
case INFINI_DTYPE_C8:
return 2;
case INFINI_DTYPE_C16: case INFINI_DTYPE_C16:
return 4; return 2;
case INFINI_DTYPE_C32: case INFINI_DTYPE_C32:
return 8; return 4;
case INFINI_DTYPE_C64: case INFINI_DTYPE_C64:
return 8;
case INFINI_DTYPE_C128:
return 16; return 16;
case INFINI_DTYPE_BF16: case INFINI_DTYPE_BF16:
return 2; return 2;
...@@ -83,14 +83,14 @@ inline std::string infiniDtypeToString(infiniDtype_t dtype) { ...@@ -83,14 +83,14 @@ inline std::string infiniDtypeToString(infiniDtype_t dtype) {
return "F32"; return "F32";
case INFINI_DTYPE_F64: case INFINI_DTYPE_F64:
return "F64"; return "F64";
case INFINI_DTYPE_C8:
return "C8";
case INFINI_DTYPE_C16: case INFINI_DTYPE_C16:
return "C16"; return "C16";
case INFINI_DTYPE_C32: case INFINI_DTYPE_C32:
return "C32"; return "C32";
case INFINI_DTYPE_C64: case INFINI_DTYPE_C64:
return "C64"; return "C64";
case INFINI_DTYPE_C128:
return "C128";
case INFINI_DTYPE_BF16: case INFINI_DTYPE_BF16:
return "BF16"; return "BF16";
default: default:
......
target("infiniutils-test") target("infiniutils-test")
set_kind("binary") set_kind("binary")
add_deps("infini-utils") add_deps("infini-utils")
on_install(function (target) end)
set_warnings("all", "error") set_warnings("all", "error")
set_languages("cxx17") set_languages("cxx17")
add_files(os.projectdir().."/src/utils-test/*.cc") add_files(os.projectdir().."/src/utils-test/*.cc")
set_installdir(os.getenv("INFINI_ROOT") or (os.getenv(is_host("windows") and "HOMEPATH" or "HOME") .. "/.infini"))
target_end()
target("infiniop-test") target("infiniop-test")
set_kind("binary") set_kind("binary")
add_deps("infini-utils") add_deps("infini-utils")
on_install(function (target) end)
set_default(false) set_default(false)
local INFINI_ROOT = os.getenv("INFINI_ROOT") or (os.getenv(is_host("windows") and "HOMEPATH" or "HOME") .. "/.infini") local INFINI_ROOT = os.getenv("INFINI_ROOT") or (os.getenv(is_host("windows") and "HOMEPATH" or "HOME") .. "/.infini")
...@@ -31,4 +31,6 @@ target("infiniop-test") ...@@ -31,4 +31,6 @@ target("infiniop-test")
add_includedirs(os.projectdir().."/src/infiniop-test/include") add_includedirs(os.projectdir().."/src/infiniop-test/include")
add_files(os.projectdir().."/src/infiniop-test/src/*.cpp") add_files(os.projectdir().."/src/infiniop-test/src/*.cpp")
add_files(os.projectdir().."/src/infiniop-test/src/ops/*.cpp") add_files(os.projectdir().."/src/infiniop-test/src/ops/*.cpp")
set_installdir(INFINI_ROOT)
target_end() target_end()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment