Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
74a52b6
fix: 修改xmake build和install的提示信息
PanZezhong1725 Dec 4, 2024
765cc56
Merge pull request #125 from PanZezhong1725/xmake_fix
PanZezhong1725 Dec 4, 2024
5ca7ccd
add ascend random sample
Dec 4, 2024
360dee3
fix random_sample test
Dec 4, 2024
8fbcfe7
modify xmake.lua and main.yaml
kilinchange Dec 4, 2024
70aaae1
update README
kilinchange Dec 4, 2024
09e3b0b
fix bug
Dec 4, 2024
588f6e3
remove os.setenv
kilinchange Dec 4, 2024
92e2d06
Merge pull request #126 from PanZezhong1725/update_installation_process
PanZezhong1725 Dec 5, 2024
2ef577c
Merge branch 'dev' of github.com:PanZezhong1725/operators into ascend…
Dec 5, 2024
2c30a13
delete rms cnnl
xgqdut2016 Dec 5, 2024
0ab53f1
Merge pull request #128 from PanZezhong1725/rms_delete
PanZezhong1725 Dec 5, 2024
171418f
fix ub overflow
Dec 5, 2024
f33f6a2
fix: fix for windows
YdrMaster Dec 6, 2024
c15ce20
rm old randomsample
Dec 9, 2024
65111d9
Merge branch 'dev' of github.com:PanZezhong1725/operators into ascend…
Dec 9, 2024
3d11a03
delete old infer storage shape code
Dec 9, 2024
a6e5e2b
add infiniOp DT to aclDataType transfer func
Dec 9, 2024
a30ca26
Merge pull request #130 from YdrMaster/main
PanZezhong1725 Dec 9, 2024
43e65e8
fix randomsample new defination
Dec 9, 2024
c1d21a7
modifed utils warning
xgqdut2016 Dec 10, 2024
fa8bbeb
fix: 更改seed的边界值处理
PanZezhong1725 Dec 10, 2024
275ace2
modified utils.h
xgqdut2016 Dec 10, 2024
55ac2b6
Merge pull request #127 from PanZezhong1725/ascend-random-sample
PanZezhong1725 Dec 10, 2024
1838557
Merge pull request #131 from PanZezhong1725/utils_warn
PanZezhong1725 Dec 10, 2024
16abf98
Change dynamic stack array to std::vector
Ziminli Dec 10, 2024
380f65c
fix: fix every error for cuda on windows
YdrMaster Dec 11, 2024
5a67281
Merge pull request #132 from YdrMaster/main
PanZezhong1725 Dec 16, 2024
ff54fb1
fix: 修复cuda代码中的类型错误
PanZezhong1725 Dec 16, 2024
745a4b8
Merge pull request #133 from PanZezhong1725/fix_cuda_
PanZezhong1725 Dec 16, 2024
9f6b19d
fix(cpu): 为 rearrange 支持 ndim == 1
YdrMaster Dec 16, 2024
f28604e
Merge pull request #134 from YdrMaster/main
PanZezhong1725 Dec 17, 2024
0200c75
fix(nv): 为 rearrange 支持 ndim == 1
YdrMaster Dec 17, 2024
a03df4e
fix: 所有 unsigned long int 替换为 uint64_t
YdrMaster Dec 17, 2024
d44beb0
fix(nv): 改正 rearrange
YdrMaster Dec 17, 2024
9214a89
Merge pull request #135 from YdrMaster/main
PanZezhong1725 Dec 18, 2024
f43df84
fix: random sample测试使用确定的分布
PanZezhong1725 Dec 18, 2024
f74eca1
Merge pull request #136 from PanZezhong1725/random_sample_test
PanZezhong1725 Dec 18, 2024
9d25304
add cpu concat
spike-zhu Dec 20, 2024
6933d38
feat(cpu): support concat negative axis
spike-zhu Dec 23, 2024
2870b4e
update2
spike-zhu Dec 24, 2024
b634397
feat: add CUDA support to concat
spike-zhu Jan 2, 2025
3b34b85
suuport conv
spike-zhu Feb 14, 2025
cd12946
Add support Conv and pooling
spike-zhu Feb 21, 2025
eaddbbc
merge concat to musa
spike-zhu Feb 21, 2025
9a0f5c8
support concat on MUSA
spike-zhu Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:

- name: Install Python dependencies
run: |
pip install numpy
pip install torch

- name: Install xmake
Expand All @@ -33,15 +34,15 @@ jobs:
- name: configure xmake
run: xmake f --cpu=true -cv

- name: Build with XMake
run: xmake

- name: Find and Set INFINI_ROOT
id: set_infini_root
- name: Set INFINI_ROOT
run: |
export INFINI_ROOT=$GITHUB_WORKSPACE
export INFINI_ROOT=$GITHUB_WORKSPACE/.infini
mkdir -p $INFINI_ROOT
echo "INFINI_ROOT=$INFINI_ROOT" >> $GITHUB_ENV

- name: Build with XMake
run: xmake build && xmake install

- name: Run Python Tests
run: |
GREEN='\033[0;32m'
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ infiniopStatus_t infiniopDestroyTensorDescriptor(infiniopTensorDescriptor_t desc

## 一、使用说明

### 配置
### 1. 配置

#### 查看当前配置

Expand Down Expand Up @@ -99,23 +99,27 @@ xmake f --nv-gpu=true --cuda=$CUDA_HOME -cv
xmake f --cambricon-mlu=true -cv
```

### 编译
#### 配置 NPU

````xmake
xmake f --ascend-npu=true -cv
````

### 2. 编译安装

```xmake
xmake
xmake build && xmake install
```

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

```bash
export INFINI_ROOT=[PATH_TO_LIBRARY]
```
按输出提示设置 `INFINI_ROOT` 和 `LD_LIBRARY_PATH` 环境变量。

### 运行算子测试
### 4. 运行算子测试

```bash
cd operatorspy/tests
python operator_name.py
python operator_name.py [--cpu | --cuda | --cambricon | --ascend]
```

## 二、开发说明
Expand Down
4 changes: 3 additions & 1 deletion include/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typedef struct DataLayout {
mantissa : 8,
exponent : 8;

#ifdef __cplusplus
bool operator==(const DataLayout &other) const {
union TypePun {
DataLayout layout;
Expand All @@ -24,12 +25,13 @@ typedef struct DataLayout {
bool operator!=(const DataLayout &other) const {
return !(*this == other);
}
#endif
} DataLayout;

typedef struct DataLayout DT;

// clang-format off
constexpr static struct DataLayout
const static struct DataLayout
I8 = {1, 1, 1, 7, 0},
I16 = {1, 1, 2, 15, 0},
I32 = {1, 1, 4, 31, 0},
Expand Down
27 changes: 27 additions & 0 deletions include/ops/concat/concat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CONCAT_H
#define CONCAT_H

#include "../../export.h"
#include "../../operators.h"

typedef struct ConcatDescriptor {
Device device;
} ConcatDescriptor;

typedef ConcatDescriptor *infiniopConcatDescriptor_t;

__C __export infiniopStatus_t infiniopCreateConcatDescriptor(infiniopHandle_t handle,
infiniopConcatDescriptor_t *desc_ptr,
infiniopTensorDescriptor_t y,
infiniopTensorDescriptor_t *x,
uint64_t num_inputs,
int64_t axis);

__C __export infiniopStatus_t infiniopConcat(infiniopConcatDescriptor_t desc,
void *y,
void const **x,
void *stream);

__C __export infiniopStatus_t infiniopDestroyConcatDescriptor(infiniopConcatDescriptor_t desc);

#endif
4 changes: 2 additions & 2 deletions include/ops/gemm/gemm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ __C __export infiniopStatus_t infiniopCreateGEMMDescriptor(infiniopHandle_t hand
infiniopTensorDescriptor_t c_desc,
float alpha,
float beta,
bool transA,
bool transB);
char transA,
char transB);

__C __export infiniopStatus_t infiniopGetGEMMWorkspaceSize(infiniopGEMMDescriptor_t desc, uint64_t *size);

Expand Down
2 changes: 1 addition & 1 deletion include/ops/mlp/mlp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ __C __export infiniopStatus_t infiniopCreateMLPDescriptor(infiniopHandle_t handl
infiniopTensorDescriptor_t w12_desc,
infiniopTensorDescriptor_t w3_desc,
float alpha,
bool residual);
char residual);

__C __export infiniopStatus_t infiniopGetMLPWorkspaceSize(infiniopMLPDescriptor_t desc, uint64_t *size);

Expand Down
3 changes: 0 additions & 3 deletions operatorspy/liboperators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

LIB_OPERATORS_DIR = os.path.join(os.environ.get("INFINI_ROOT"), "lib")


class TensorDescriptor(Structure):
_fields_ = [
("dt", DataLayout),
Expand All @@ -19,10 +18,8 @@ class TensorDescriptor(Structure):
("pattern", POINTER(c_int64)),
]


infiniopTensorDescriptor_t = ctypes.POINTER(TensorDescriptor)


class CTensor:
def __init__(self, desc, data):
self.descriptor = desc
Expand Down
6 changes: 1 addition & 5 deletions operatorspy/tests/avg_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ def test(
elapsed = (time.time() - start_time) / NUM_ITERATIONS
print(f" lib time: {elapsed :6f}")


print(x)
print(y)
print(ans)
assert torch.allclose(y, ans, atol=0, rtol=1e-3)
check_error(lib.infiniopDestroyAvgPoolDescriptor(descriptor))

Expand Down Expand Up @@ -205,7 +201,7 @@ def test_musa(lib, test_cases):
# ((1, 1, 10), (3,), (1,), (1,)),
((1, 1, 2, 2), (2, 2), (1, 1), (1, 1)),
((32, 4, 224, 224), (3, 3), (1, 1), (2, 2)),
((1, 1, 16, 16, 16), (5, 5, 5), (2, 2, 2), (2, 2, 2)),
# ((1, 1, 16, 16, 16), (5, 5, 5), (2, 2, 2), (2, 2, 2)),
]
args = get_args()
lib = open_lib()
Expand Down
Loading