Skip to content

Commit

Permalink
Merge pull request #14 from PAICookers/dev
Browse files Browse the repository at this point in the history
🔖 1.1.0
  • Loading branch information
KafCoppelia authored May 18, 2023
2 parents 3d08e56 + 7bc1c87 commit 48fbe08
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 121 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Release Drafter
on:
push:
branches:
- master
- dev
- main

pull_request:
types: [opened, reopened, synchronize]
Expand All @@ -22,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: master
ref: main

- name: Setup Poetry
uses: Gr1N/setup-poetry@v8
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ repos:
- id: isort
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: autopep8
- id: black
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

## 📦 版本

[v1.0.1](https://github.com/PAICookers/PAITest/releases/tag/v1.0.1)
[v1.1.0](https://github.com/PAICookers/PAITest/releases/tag/v1.1.0)

支持 `.txt` 格式输出
支持大/小端格式输出

## 🛠️ 使用生成

Expand Down Expand Up @@ -39,7 +39,7 @@
save_dir=save_to_dir, masked_core_coord=(12, 16), gen_txt=True)
```

⚠️ 指定 `verbose=True` 以开启日志显示,默认关闭;指定 `gen_txt=True` 以保存至 `.txt`,默认保存至 `.bin`
⚠️ 指定 `verbose=True` 以开启日志显示,默认关闭

3. `Get1GroupForNCoresWith1Param`,产生1组针对 `N` 个核的配置-测试帧,每个核配置**相同参数**。可以指定单个需要**屏蔽**的核坐标

Expand All @@ -64,16 +64,18 @@

⚠️ 一组指一组完整的配置帧,包含3帧。对于测试输入帧,即为单帧。

6. `SaveFrames`默认保存帧数据至指定文件,支持 `.bin``.txt` 格式
6. `SaveFrames`保存帧数据至指定文件,支持 `.bin``.txt` 格式,支持指定大/小端输出

```python
# Save into binary files
PAITestManager.SaveFrames("./test/config.bin", replaced)
# Save into binary files with big-edian format(default)
PAITestManager.SaveFrames("./test/config.bin", replaced, byteorder="big")

# Or text files
PAITestManager.SaveFrames("./test/config.txt", replaced)
```

⚠️ 指定 `byteorder="big"/"little"` 以大/小端格式储存帧数据,默认大端

## 🗓️ TODO

- [x] 上板验证
Expand Down
20 changes: 7 additions & 13 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,31 @@
if __name__ == "__main__":
"""Here are simple exmaples"""

# Path to store the config, test input and output frames
save_path = "./test"

# N groups
groups = 1

# PAITest instance
PAITestManager = paitest("EAST")

# 1. Generate 1 group for N cores with N **different** parameters reg.
a_cf, a_ti, a_to = PAITestManager.Get1GroupForNCoresWithNParams(
3, save_dir="./test", verbose=True # Turn on the verbose mode
)
paitest.SaveFrames(
"./test/example_configframes.bin", a_cf, byteorder="big" # Big-edian format
)
print(a_cf, a_ti, a_to)

# 2. Generate 1 group for N cores with the **same** parameter reg.
a_cf, a_ti, a_to = PAITestManager.Get1GroupForNCoresWith1Param(
1, save_dir="./test")
print(a_cf, a_ti, a_to)
a_cf, a_ti, a_to = PAITestManager.Get1GroupForNCoresWith1Param(1, save_dir="./test")

# 3. Generate N groups for 1 core with N **different** parameters reg.
a_cf, a_fi, a_fo = PAITestManager.GetNGroupsFor1CoreWithNParams(
3, save_dir="./test1", gen_txt=True # Can save into .txt file as well
3, save_dir="./test1"
)

# 3. Replace the core coordinate with (9, 9) then save in test/config_r.bin
# 3. Replace the core coordinate with (9, 9)
a_cf_replaced = PAITestManager.ReplaceCoreCoord(a_cf[:3], (9, 9))
PAITestManager.SaveFrames("./test/config_r.bin", a_cf_replaced)
print(f"a_cf_replaced: {a_cf_replaced}")

# Then, decode the replaced frames to check whether the replacement is OK
# Then, decode the replaced frames to check whether the replacement is correct
decoder = FrameDecoder()
attr = decoder.decode(a_cf_replaced)

Expand Down
2 changes: 2 additions & 0 deletions paitest/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .paitest import paitest as paitest

__all__ = ["paitest"]
36 changes: 12 additions & 24 deletions paitest/frames/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ def _GenParamReg(
if not is_legal:
# Don't care 'tick_wait_start' split in #1 and #2
for _ in range(2):
param_reg.append(random.randint(
0, FM.GENERAL_PAYLOAD_MASK))
param_reg.append(random.randint(0, FM.GENERAL_PAYLOAD_MASK))

param_reg[1] = (param_reg[1] & (
~CFM.TEST_CHIP_ADDR_HIGH3_MASK)) | high3
param_reg[1] = (param_reg[1] & (~CFM.TEST_CHIP_ADDR_HIGH3_MASK)) | high3
param_reg.append(low7 << CFM.TEST_CHIP_ADDR_LOW7_OFFSET)
else:
# Do legal geenration
Expand Down Expand Up @@ -347,14 +345,12 @@ def _general_info(self) -> None:

chip_coord = self._get_chip_coord()
print(
"#2 Chip coordinate: [0x%02x | 0x%02x]" % (
chip_coord.x, chip_coord.y)
"#2 Chip coordinate: [0x%02x | 0x%02x]" % (chip_coord.x, chip_coord.y)
)

core_coord = self._get_core_coord()
print(
"#3 Core coordinate: [0x%02x | 0x%02x]" % (
core_coord.x, core_coord.y)
"#3 Core coordinate: [0x%02x | 0x%02x]" % (core_coord.x, core_coord.y)
)

core_star_coord = self._get_core_star_coord()
Expand All @@ -365,23 +361,16 @@ def _general_info(self) -> None:

def _config2_info(self) -> None:
print("Info of parameter registers")
print("#1 Weight width: 0x%x" %
self._param_reg_dict["weight_width"])
print("#1 Weight width: 0x%x" % self._param_reg_dict["weight_width"])
print("#2 LCN: 0x%x" % self._param_reg_dict["LCN"])
print("#3 Input width: 0x%x" %
self._param_reg_dict["input_width"])
print("#4 Spike width: 0x%x" %
self._param_reg_dict["spike_width"])
print("#5 Neuron num: %d" %
self._param_reg_dict["neuron_num"])
print("#3 Input width: 0x%x" % self._param_reg_dict["input_width"])
print("#4 Spike width: 0x%x" % self._param_reg_dict["spike_width"])
print("#5 Neuron num: %d" % self._param_reg_dict["neuron_num"])
print("#6 Pool max enable: %d" % self._param_reg_dict["pool_max"])
print("#7 Tick wait start: 0x%x" %
self._param_reg_dict["tick_wait_start"])
print("#8 Tick wait end: 0x%x" %
self._param_reg_dict["tick_wait_end"])
print("#7 Tick wait start: 0x%x" % self._param_reg_dict["tick_wait_start"])
print("#8 Tick wait end: 0x%x" % self._param_reg_dict["tick_wait_end"])
print("#9 SNN enable: %d" % self._param_reg_dict["SNN_EN"])
print("#10 Target LCN: 0x%x" %
self._param_reg_dict["target_LCN"])
print("#10 Target LCN: 0x%x" % self._param_reg_dict["target_LCN"])

# type: ignore
test_chip_coord: Coord = self._param_reg_dict["test_chip_coord"]
Expand Down Expand Up @@ -435,8 +424,7 @@ def _param_reg_parse(self) -> None:

high3 = self._frames_group[1] >> CFM.TEST_CHIP_ADDR_HIGH3_OFFSET
low7 = self._frames_group[2] >> CFM.TEST_CHIP_ADDR_LOW7_OFFSET
self._param_reg_dict["test_chip_coord"] = test_chip_addr_combine(
high3, low7)
self._param_reg_dict["test_chip_coord"] = test_chip_addr_combine(high3, low7)

def _decode_direction(self) -> Direction:
# type: ignore
Expand Down
Loading

0 comments on commit 48fbe08

Please sign in to comment.