Skip to content

Commit

Permalink
Merge branch 'feature/qwen' into feature/dev3_qwen
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnycase committed Jan 11, 2025
2 parents c89a494 + f407fc6 commit 1bb40e5
Show file tree
Hide file tree
Showing 143 changed files with 3,798 additions and 1,055 deletions.
2 changes: 1 addition & 1 deletion .github/disable-workflows/compiler-python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04,windows-2019,macos-10.15]
os: [ubuntu-18.04,windows-latest,macos-10.15]

steps:
- uses: actions/checkout@v2
Expand Down
26 changes: 4 additions & 22 deletions .github/workflows/compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnet-version}}
dotnet-version: '7.0.x'

- name: Cache NuGet packages
uses: actions/cache@v3
Expand Down Expand Up @@ -198,40 +198,21 @@ jobs:

- name: Set up test environment (macOS)
run: |
aria2c --parameterized-uri=true https://sdk.lunarg.com/sdk/download/${VULKANSDK_VER}/mac/vulkansdk-macos-${VULKANSDK_VER}.dmg
hdiutil attach ./vulkansdk-macos-*.dmg
sudo /Volumes/vulkansdk-macos-*/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $HOME/VulkanSDK --accept-licenses --default-answer --confirm-command install
hdiutil detach /Volumes/vulkansdk-macos-*
echo "VULKAN_SDK=$HOME/VulkanSDK/macOS" >> $GITHUB_ENV
cp install/lib/*.dylib install/
echo "PYTHONPATH=$GITHUB_WORKSPACE/install/lib:$GITHUB_WORKSPACE/install/python:$GITHUB_WORKSPACE/tests" >> $GITHUB_ENV
if: runner.os == 'macOS'

- name: Set up test environment (Linux)
run: |
wget https://sdk.lunarg.com/sdk/download/${VULKANSDK_VER}/linux/vulkansdk-linux-x86_64-${VULKANSDK_VER}.tar.xz -O vulkansdk.tar.xz
tar xf vulkansdk.tar.xz
sudo cp -P ${VULKANSDK_VER}/x86_64/lib/libvulkan.so* /usr/local/lib/
wget https://github.com/sunnycase/swiftshader/releases/download/v1.0/swiftshader-ubuntu-18.04-x86_64.zip -O swiftshader.zip
unzip swiftshader.zip
sudo cmake -E make_directory /usr/local/share/vulkan/icd.d
sudo cp lib/* /usr/local/share/vulkan/icd.d
cp install/lib/*.so install/
echo "PYTHONPATH=$GITHUB_WORKSPACE/install/lib:$GITHUB_WORKSPACE/install/python:$GITHUB_WORKSPACE/tests" >> $GITHUB_ENV
if: runner.os == 'Linux'

- name: Set up test environment (Windows)
shell: pwsh
run: |
# Invoke-WebRequest -Uri https://sdk.lunarg.com/sdk/download/${env:VULKANSDK_VER}/windows/VulkanSDK-${env:VULKANSDK_VER}-Installer.exe -O VulkanSDK-Installer.exe
# .\VulkanSDK-Installer.exe /S
Invoke-WebRequest -Uri https://github.com/sunnycase/swiftshader/releases/download/v1.0/swiftshader-windows-2019-x86_64.zip -OutFile swiftshader.zip
Expand-Archive swiftshader.zip
Copy-Item swiftshader\lib\vk_swiftshader_icd.json swiftshader\bin\
Copy-Item install/bin/*.dll install/
Copy-Item install/bin/*.dll install/lib/
echo "VK_ICD_FILENAMES=${env:GITHUB_WORKSPACE}/swiftshader/bin/vk_swiftshader_icd.json" >> $env:GITHUB_ENV
echo "PYTHONPATH=${env:GITHUB_WORKSPACE}/install/lib;${env:GITHUB_WORKSPACE}/install/python;${env:GITHUB_WORKSPACE}/tests" >> $env:GITHUB_ENV
Copy-Item install/lib/*.pyd install/bin/
echo "PYTHONPATH=${env:GITHUB_WORKSPACE}/install/bin;${env:GITHUB_WORKSPACE}/install/python;${env:GITHUB_WORKSPACE}/tests" >> $env:GITHUB_ENV
echo "PATH=${env:PATH};${env:GITHUB_WORKSPACE}/install/bin" >> $env:GITHUB_ENV
if: runner.os == 'Windows'

Expand Down Expand Up @@ -259,6 +240,7 @@ jobs:
dotnet-coverage merge -o coverage.integration.xml -f cobertura -r coverage/*.xml
- name: Upload Coverage
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4
if: matrix.config.name == 'x86_64-linux'
with:
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/compiler-python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
matrix:
dotnet-version: ['8.0']
config:
# - {name: aarch64-macos, os: macos-14, shell: bash, rid: osx-arm64, buildType: Release}
- {name: aarch64-macos, os: macos-14, shell: bash, rid: osx-arm64, buildType: Release}
- {name: x86_64-linux, os: ubuntu-24.04, shell: bash, rid: linux-x64, buildType: Release}
# - {name: x86_64-windows, os: windows-latest, shell: bash, rid: win-x64, buildType: Release}
- {name: x86_64-windows, os: windows-latest, shell: bash, rid: win-x64, buildType: Release}

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnet-version}}
dotnet-version: '7.0.x'

- name: Cache NuGet packages
uses: actions/cache@v3
Expand Down Expand Up @@ -53,20 +53,19 @@ jobs:
matrix:
dotnet-version: ['8.0']
config:
# - {name: aarch64-macos, os: macos-14}
- {name: aarch64-macos, os: macos-14}
- {name: x86_64-linux, os: ubuntu-24.04}
# - {name: x86_64-windows, os: windows-latest, arch: x64}

env:
VULKANSDK_VER: 1.3.268.0
- {name: x86_64-windows, os: windows-latest, arch: x64}

steps:
- uses: actions/checkout@v3

- uses: seanmiddleditch/gha-setup-ninja@master

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnet-version}}
dotnet-version: '7.0.x'

- name: Install nncase
uses: actions/download-artifact@v4
Expand All @@ -80,19 +79,14 @@ jobs:
arch: ${{matrix.config.arch}}
if: runner.os == 'Windows'

- name: Set up build environment (Macos)
run: |
brew install sunnycase/core/[email protected]
if: runner.os == 'Macos'

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install cibuildwheel
run: pip install cibuildwheel

- name: Build wheel
run: python -m cibuildwheel --output-dir wheelhouse

Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,9 @@ cmake-build-*
*.ipynb_checkpoints*
# Auto generated files
# generated/
.history/

.mono/
.history/

# set dotnet version
global.json
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ option(BUILD_BENCHMARK "Build benchmark programs" ON)
option(BUILD_TESTING "Build test programs" OFF)
option(ENABLE_OP_PROFILE "Profile ops cast time" OFF)
option(ENABLE_DUMP_MANAGER "Enable dump manager" OFF)
option(ENABLE_RVV "Some kernel impl by rvv" OFF)
option(ENABLE_DUMP_MEM "Dump mem usage" OFF)

if (BUILDING_RUNTIME)
# option(ENABLE_VULKAN_RUNTIME "Enable Vulkan runtime" OFF)
option(ENABLE_K210_RUNTIME "Enable k210 runtime" OFF)
option(DEFAULT_BUILTIN_RUNTIMES "Use default builtin runtimes" ON)
option(DEFAULT_SHARED_RUNTIME_TENSOR_PLATFORM_IMPL "Use default shared memory platform impl" ON)
endif()

if (BUILDING_RUNTIME)
option(ENABLE_VULKAN_RUNTIME "Enable Vulkan runtime" OFF)
option(ENABLE_K210_RUNTIME "Enable k210 runtime" OFF)
Expand Down
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<NoWarn>$(NoWarn);MSB3270;CS0659;CS0661</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="11.0.2" />
Expand All @@ -28,6 +28,8 @@
<PackageVersion Include="Extension.Mathematics" Version="1.2.12" />
<PackageVersion Include="Fody" Version="6.8.1" />
<PackageVersion Include="GiGraph.Dot" Version="3.0.1" />
<PackageVersion Include="QuikGraph" Version="2.5.0" />
<PackageVersion Include="QuikGraph.Graphviz" Version="2.5.0" />
<PackageVersion Include="Google.Protobuf" Version="3.27.3" />
<PackageVersion Include="Grpc.Tools" Version="2.65.0" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
Telegram: [nncase community](https://t.me/joinchat/PPcEPZMLaTViNDI1)
Technical Discussion QQ Group: 790699378 . Answer: 人工智能

[TOC]

---

## K230
Expand Down Expand Up @@ -76,9 +74,9 @@ All version of `nncase` and `nncase-kpu` in [Release](https://github.com/kendryt

### Demo

|[eye gaze](https://developer.canaan-creative.com/devAdmin/model/download?mid=be978f1f38b8aa2f2b649185a10c2e9c&filePath=/upload/model/official/k230/yolop_lane_seg/yolop_lane_seg.zip) | [space_resize](https://developer.canaan-creative.com/devAdmin/model/download?mid=7d48cb68a499dd54daf0ced14549b142&filePath=/upload/model/official/k230/space_resize/space_resize.zip) | [face pose](https://developer.canaan-creative.com/devAdmin/model/download?mid=5b87c02b969a9e60d48b08e357c20e31&filePath=/upload/model/official/k230/face_pose/face_pose.zip) |
|---|---|---|
|<img src="https://github.com/kendryte/nncase_docs/blob/master/gif/eye_gaze_result.gif?raw=true" alt="gif"> | <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/space_resize.gif?raw=true" alt="gif">| <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/face_pose_result.gif?raw=true">|
|[eye gaze](https://developer.canaan-creative.com/modelDetail?id=142) | [space_resize](https://developer.canaan-creative.com/modelDetail?id=141) | [face pose](https://developer.canaan-creative.com/modelDetail?id=125)|
| --- | --- | --- |
| <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/eye_gaze_result.gif?raw=true" alt="gif"> | <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/space_resize.gif?raw=true" alt="gif">| <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/face_pose_result.gif?raw=true"> |

---

Expand Down
9 changes: 8 additions & 1 deletion docs/FAQ_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ If 'XXX' belongs to quantization-related operators such as `FAKE_QUANT`, `DEQUAN
A: Use `sudo gedit /proc/sys/fs/inotify/max_user_instances` to change 128 to a larger value.

### 2.3 `RuntimeError: Failed to initialize hostfxr`
> `RuntimeError: Failed to get hostfxr path.`
A:Need to install dotnet-sdk-7.0.
A:Need to install dotnet-sdk-7.0. Do not install `dotnet` in `anaconda` virtual environment.

- Linux:

Expand All @@ -37,6 +38,12 @@ A:Need to install dotnet-sdk-7.0.
sudo apt-get install dotnet-sdk-7.0
```

If you still have problems after installation, maybe you install dotnet in a virtual enviroment, set the environment variables. [dotnet error](https://stackoverflow.com/questions/52695238/whats-the-expected-value-for-dotnet-root-variable-when-installing-dotnet-core-f)

```shell
export DOTNET_ROOT=/usr/share/dotnet
```

- Windows: Refer to MicroSoft official website.

### 2.4 "KeyNotFoundException: The given key 'K230' was not present in the dictionary"
Expand Down
9 changes: 8 additions & 1 deletion docs/FAQ_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ A:该异常表明 `XXX`算子尚未支持,可以在[nncase Github Issue](htt
A:使用 `sudo gedit /proc/sys/fs/inotify/max_user_instances`修改128为更大的值即可。

### 2.3 `RuntimeError: Failed to initialize hostfxr`
> `RuntimeError: Failed to get hostfxr path.`
A:需要安装dotnet-sdk-7.0
A:需要安装dotnet-sdk-7.0,不要在`anaconda`的虚拟环境中安装。
- Linux:

```shell
sudo apt-get update
sudo apt-get install dotnet-sdk-7.0
```

如果安装完毕后仍然报类似的错误,配置`dotnet`环境变量。 [dotnet error](https://stackoverflow.com/questions/52695238/whats-the-expected-value-for-dotnet-root-variable-when-installing-dotnet-core-f)

```shell
export DOTNET_ROOT=/usr/share/dotnet
```

- Windows: 请自行查阅微软官方文档。

### 2.4 "KeyNotFoundException: The given key 'K230' was not present in the dictionary"
Expand Down
8 changes: 4 additions & 4 deletions docs/MixQuant.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ ptq_options.export_quant_scheme = False
ptq_options.export_weight_range_by_channel = False
```

* **quant_scheme:导入量化参数配置文件的路径**
* **quant_scheme_strict_mode:是否严格按照quant_scheme执行量化**
* **export_quant_scheme:是否导出量化参数配置文件**
* **export_weight_range_by_channel:是否导出** `bychannel`形式的weights量化参数,为了保证量化效果,该参数建议设置为 `True`
* **quant_scheme**:导入量化参数配置文件的路径
* **quant_scheme_strict_mode**:是否严格按照quant_scheme执行量化
* **export_quant_scheme**:是否导出量化参数配置文件
* **export_weight_range_by_channel**:是否导出 `bychannel`形式的weights量化参数,为了保证量化效果,该参数建议设置为 `True`

---

Expand Down
3 changes: 3 additions & 0 deletions docs/USAGE_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ subgraph A
end

```

>如果你在编译`kmodel`时使用了前处理相关的配置,当你需要使用`ONNX`或者`TFLite`框架进行结果验证时,需要在你的`ONNX`或者`TFLite` pipeline中增加相应的前处理操作,这样才能保证和`kmodel` pipeline是等价的。

##### 动态shape参数
详见[动态shape参数说明](./shape_bucket.md)

Expand Down
5 changes: 4 additions & 1 deletion docs/USAGE_v2_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ subgraph A
```

> If you have utilized pre-processing configurations when compiling the `kmodel`, when you need to verify the results using the `ONNX` or `TFLite` framework, you must add the corresponding pre-processing operations to your `ONNX` or `TFLite` pipeline to ensure equivalence between the `kmodel` pipeline.

##### Dynamice shape args
Refer to[Dynamic shape args description](./shape_bucket.md)
Refer to [Dynamic shape args description](./shape_bucket.md)

#### Example

Expand Down
8 changes: 4 additions & 4 deletions docs/readme_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Telegram: [nncase community](https://t.me/joinchat/PPcEPZMLaTViNDI1)

### 支持的算子

- [TFLite ops](./docs/tflite_ops.md)
- [Caffe ops](./docs/caffe_ops.md)
- [ONNX ops](./docs/onnx_ops.md)
- [TFLite ops](https://github.com/kendryte/nncase/blob/release/2.0/docs/tflite_ops.md)
- [Caffe ops](https://github.com/kendryte/nncase/blob/release/2.0/docs/caffe_ops.md)
- [ONNX ops](https://github.com/kendryte/nncase/blob/release/2.0/docs/onnx_ops.md)

### benchmark test

Expand Down Expand Up @@ -74,7 +74,7 @@ Telegram: [nncase community](https://t.me/joinchat/PPcEPZMLaTViNDI1)

### Demo示例

|[eye gaze](https://developer.canaan-creative.com/devAdmin/model/download?mid=be978f1f38b8aa2f2b649185a10c2e9c&filePath=/upload/model/official/k230/yolop_lane_seg/yolop_lane_seg.zip) | [space_resize](https://developer.canaan-creative.com/devAdmin/model/download?mid=7d48cb68a499dd54daf0ced14549b142&filePath=/upload/model/official/k230/space_resize/space_resize.zip) | [face pose](https://developer.canaan-creative.com/devAdmin/model/download?mid=5b87c02b969a9e60d48b08e357c20e31&filePath=/upload/model/official/k230/face_pose/face_pose.zip) |
|[eye gaze](https://developer.canaan-creative.com/modelDetail?id=142) | [space_resize](https://developer.canaan-creative.com/modelDetail?id=141) | [face pose](https://developer.canaan-creative.com/modelDetail?id=125) |
|---|---|---|
|<img src="https://github.com/kendryte/nncase_docs/blob/master/gif/eye_gaze_result.gif?raw=true" alt="gif"> | <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/space_resize.gif?raw=true" alt="gif">| <img src="https://github.com/kendryte/nncase_docs/blob/master/gif/face_pose_result.gif?raw=true">|

Expand Down
8 changes: 6 additions & 2 deletions examples/user_guide/k230_simulate-EN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@
"source": [
"# 5. Compare kmodel result and tflite result.\n",
"\n",
"Here, we will use the TensorFlow framework to infer model(`.tflite`, not kmodel). And calculate the cosine between the tflite result and kmodel result."
"Here, we will use the TensorFlow framework to infer model(`.tflite`, not kmodel). And calculate the cosine between the tflite result and kmodel result.\n",
"\n",
"> If you have utilized pre-processing configurations when compiling the `kmodel`, when you need to verify the results using the `ONNX` or `TFLite` framework, you must add the corresponding pre-processing operations to your `ONNX` or `TFLite` pipeline to ensure equivalence between the `kmodel` pipeline."
]
},
{
Expand Down Expand Up @@ -385,7 +387,9 @@
"source": [
"# 8. Compare kmodel results and onnx results.\n",
"\n",
"Here, we will use the ONNX framework to infer model(`.onnx`, not kmodel). And calculate the cosine between the ONNX result and the kmodel result."
"Here, we will use the ONNX framework to infer model(`.onnx`, not kmodel). And calculate the cosine between the ONNX result and the kmodel result.\n",
"\n",
"> If you have utilized pre-processing configurations when compiling the `kmodel`, when you need to verify the results using the `ONNX` or `TFLite` framework, you must add the corresponding pre-processing operations to your `ONNX` or `TFLite` pipeline to ensure equivalence between the `kmodel` pipeline."
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions examples/user_guide/k230_simulate-ZH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@
"source": [
"# 5. 比较TF结果和kmodel的推理结果\n",
"\n",
"这里,我们使用TensorFlow框架来推理`.tflite`模型,然后计算TensorFlow输入结果和kmodel的输出结果的余弦。"
"这里,我们使用TensorFlow框架来推理`.tflite`模型,然后计算TensorFlow输入结果和kmodel的输出结果的余弦。\n",
"\n",
">如果你在编译`kmodel`时使用了前处理相关的配置,当你需要使用`ONNX`或者`TFLite`框架进行结果验证时,需要在你的`ONNX`或者`TFLite` pipeline中增加相应的前处理操作,这样才能保证和`kmodel` pipeline是等价的。"
]
},
{
Expand Down Expand Up @@ -386,7 +388,9 @@
"source": [
"# 8. 比较ONNX结果和kmodel推理结果\n",
"\n",
"这里给出如何调用ONNX框架推理的示例代码,以及如何将ONNX的推理结果和kmodel的推理结果进行比较,该比较结果为余弦值的形式。<br>"
"这里给出如何调用ONNX框架推理的示例代码,以及如何将ONNX的推理结果和kmodel的推理结果进行比较,该比较结果为余弦值的形式。\n",
"\n",
"> 如果你在编译`kmodel`时使用了前处理相关的配置,当你需要使用`ONNX`或者`TFLite`框架进行结果验证时,需要在你的`ONNX`或者`TFLite` pipeline中增加相应的前处理操作,这样才能保证和`kmodel` pipeline是等价的。"
]
},
{
Expand Down
Loading

0 comments on commit 1bb40e5

Please sign in to comment.