README.md 1.89 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# InfiniOP 测例生成

## 介绍

使用 python 脚本生成包含测例的 `.gguf` 文件,并使用 `infiniop-test` 程序进行测试。

## 运行方式

- 编译 `infiniop-test` 程序

```bash
xmake build infiniop-test
```

- 生成测例

PanZezhong's avatar
PanZezhong committed
17
`/test/infiniop-test/`目录执行矩阵乘测例生成脚本,执行结束以后会在`/test/infiniop-test/`目录生成`gemm.gguf`测例文件。
18
19
20

```bash
cd /test/infiniop-test/
PanZezhong's avatar
PanZezhong committed
21
python -m test_generate.testcases.gemm
22
23
24
25
26
27
28
29
30
31
```

- 测试测例

打印测试程序用法

```bash
infiniop-test --help
```

PanZezhong's avatar
PanZezhong committed
32
示例:在CPU上测试`gemm.gguf`测例文件,预热20次,测试1000次。
33
34

```bash
PanZezhong's avatar
PanZezhong committed
35
infiniop-test gemm.gguf --cpu --warmup 20 --run 1000
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
```

## 自定义测例

### GGUF文件格式

```text
GGUF File Contents:
Version: 3
Number of Meta KVs: 8
Number of Tensors: 4

Meta KVs:
Key: general.architecture, Type: GGUF_TYPE_STRING, Value: infiniop-test
Key: test_count, Type: GGUF_TYPE_UINT64, Value: 1
Key: test.0.op_name, Type: GGUF_TYPE_STRING, Value: matmul
Key: test.0.a.strides, Type: GGUF_TYPE_INT32, Value: [1, 5]
Key: test.0.b.strides, Type: GGUF_TYPE_INT32, Value: [1, 6]
Key: test.0.c.strides, Type: GGUF_TYPE_INT32, Value: [1, 6]
Key: test.0.alpha, Type: GGUF_TYPE_FLOAT32, Value: 1.000000
Key: test.0.beta, Type: GGUF_TYPE_FLOAT32, Value: 0.000000

Tensor INFOs:
Name: test.0.a, NDims: 2, Shape: [5, 4], DataType: F32, DataOffset: 0
Name: test.0.b, NDims: 2, Shape: [6, 5], DataType: F32, DataOffset: 96
Name: test.0.c, NDims: 2, Shape: [6, 4], DataType: F32, DataOffset: 224
Name: test.0.ans, NDims: 2, Shape: [6, 4], DataType: F64, DataOffset: 320
```

- `Meta` 中必须包含 `test_count` ,表示测例数量。
- 每个测例的 `Meta``Tensor` 名字以 `test.[id].` 开头,后接具体信息名称。数字 `[id]` 表示测例编号。编号必须为 0 到 test_count-1.
- `Tensor` 名字接 `.strides` 表示步长,若没有则默认为连续。