Skip to content

Commit

Permalink
Merge branch 'master' into release/2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyang2057 committed Nov 28, 2023
2 parents c8cb666 + 87aa407 commit 359e6d4
Show file tree
Hide file tree
Showing 428 changed files with 12,140 additions and 4,278 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
dotnet restore -r ${{matrix.config.rid}}
dotnet build -c ${{matrix.config.buildType}} --no-restore
dotnet publish src/Nncase.Compiler -c ${{matrix.config.buildType}} --no-restore --sc false -r ${{matrix.config.rid}}
dotnet publish src/Nncase.Studio -c ${{matrix.config.buildType}} --no-restore --sc false -r ${{matrix.config.rid}}
- name: Set up Dotnet Test settings
uses: 1arp/create-a-file-action@0.2
Expand Down
250 changes: 125 additions & 125 deletions .github/workflows/runtime-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: runtime-build

on: [push, pull_request]
on: [ push, pull_request ]

concurrency:
group: runtime-build-${{ github.ref }}
Expand All @@ -13,71 +13,71 @@ jobs:
strategy:
matrix:
config:
- {name: x86_64-macos, os: macos-latest, cmakeArgs: '', buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, cmakeArgs: '', buildType: Release}
- {name: x86_64-windows, os: windows-latest, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release}
- { name: x86_64-macos, os: macos-latest, cmakeArgs: '', buildType: Release }
- { name: x86_64-linux, os: ubuntu-latest, cmakeArgs: '', buildType: Release }
- { name: x86_64-windows, os: windows-latest, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release }

steps:
- uses: actions/checkout@v3
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Set up build environment (Windows, Visual Studio)
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.config.arch}}
if: runner.os == 'Windows'

- name: Set up build environment (Macos)
run: |
brew install sunnycase/core/libomp@11.1.0
if: runner.os == 'Macos'

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

- name: Install Conan
run: |
pip install conan==1.58
conan remote add -i 0 sunnycase https://conan.sunnycase.moe
- name: Configure Conan (Linux)
run: |
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile update settings.compiler.version=10 default
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
if: runner.os == 'Linux'

- name: Configure CMake
shell: bash
run: |
conan install . -if build --build=missing -s build_type=${{matrix.config.buildType}} --profile=default -o runtime=True -o python=False -o tests=True -s compiler.cppstd=17
- name: Build & Install
run: |
conan build . -if build -bf build
cmake --install build --prefix install
- name: Test
run: |
cd build
ctest -C ${{matrix.config.buildType}} --test-dir tests/kernels --output-on-failure -j4
if: runner.os != 'Macos' && runner.os != 'Windows'

#- name: Benchmark
# run: |
# ${{github.workspace}}/install/bin/benchnncase > benchnncase.log
# cat benchnncase.log

- name: Upload nncaseruntime Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncaseruntime-${{matrix.config.name}}
path: ${{github.workspace}}/install
if-no-files-found: error
- uses: actions/checkout@v3
- uses: seanmiddleditch/gha-setup-ninja@master

- name: Set up build environment (Windows, Visual Studio)
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.config.arch}}
if: runner.os == 'Windows'

- name: Set up build environment (Macos)
run: |
brew install sunnycase/core/libomp@11.1.0
if: runner.os == 'Macos'

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

- name: Install Conan
run: |
pip install conan==1.58
conan remote add -i 0 sunnycase https://conan.sunnycase.moe
- name: Configure Conan (Linux)
run: |
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile update settings.compiler.version=10 default
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
if: runner.os == 'Linux'

- name: Configure CMake
shell: bash
run: |
conan install . -if build --build=missing -s build_type=${{matrix.config.buildType}} --profile=default -o runtime=True -o python=False -o tests=True -s compiler.cppstd=17
- name: Build & Install
run: |
conan build . -if build -bf build
cmake --install build --prefix install
- name: Test
run: |
cd build
ctest -C ${{matrix.config.buildType}} --test-dir tests/kernels --output-on-failure -j4
if: runner.os != 'Macos' && runner.os != 'Windows'

#- name: Benchmark
# run: |
# ${{github.workspace}}/install/bin/benchnncase > benchnncase.log
# cat benchnncase.log

- name: Upload nncaseruntime Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncaseruntime-${{matrix.config.name}}
path: ${{github.workspace}}/install
if-no-files-found: error

#- name: Upload nncaseruntime Benchmark
# uses: actions/upload-artifact@v3
Expand All @@ -87,64 +87,64 @@ jobs:
# if-no-files-found: error

build-cross-linux-runtime:
name: build-runtime-${{matrix.config.name}}
runs-on: ubuntu-latest
strategy:
matrix:
config:
- {name: riscv64-linux, shell: bash, arch: riscv64, toolchain: riscv64-unknown-linux, toolchain_env: RISCV_ROOT_PATH, toolchain_file: riscv64-unknown-linux-gnu-12.0.1, qemu: qemu-riscv64, loader_args: '-cpu;rv64,v=true,Zfh=true,vlen=128,elen=64,vext_spec=v1.0;-L', cmakeArgs: '', buildType: Release}

steps:
- uses: actions/checkout@v3
- uses: seanmiddleditch/gha-setup-ninja@master

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

- name: Install toolchain and QEMU
shell: bash
run: |
wget https://dav.sunnycase.moe/d/ci/nncase/${{matrix.config.toolchain_file}}.tar.xz -O toolchain.tar.xz
sudo tar xf toolchain.tar.xz -C $GITHUB_WORKSPACE
echo "${{matrix.config.toolchain_env}}=$GITHUB_WORKSPACE/${{matrix.config.toolchain_file}}" >> $GITHUB_ENV
wget https://dav.sunnycase.moe/d/ci/nncase/${{matrix.config.qemu}}.tgz -O qemu.tgz
sudo tar xf qemu.tgz -C /usr/local/bin
echo "TESTS_EXECUTABLE_LOADER=${{matrix.config.qemu}}" >> $GITHUB_ENV
echo "TESTS_EXECUTABLE_LOADER_ARGUMENTS=${{matrix.config.loader_args}};$GITHUB_WORKSPACE/${{matrix.config.toolchain_file}}/sysroot" >> $GITHUB_ENV
- name: Install Conan
run: |
pip install conan==1.58
conan remote add -i 0 sunnycase https://conan.sunnycase.moe
- name: Configure Conan
run: |
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan config init
sed -i 's/xtensalx7]/xtensalx7, ${{matrix.config.arch}}]/g' ~/.conan/settings.yml
- name: Configure CMake
run: |
conan install . -if build --build=missing -s build_type=${{matrix.config.buildType}} --profile:host=toolchains/riscv64-unknown-linux.profile.jinja --profile:build=default -o runtime=True -o python=False -o tests=True -s compiler.cppstd=17
- name: Build & Install
run: |
conan build . -if build -bf build
cmake --install build --prefix install
- name: Test
shell: bash
run: |
cd build
ctest --test-dir tests/kernels --output-on-failure -j4
- name: Upload nncaseruntime Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncaseruntime-${{matrix.config.name}}
path: ${{github.workspace}}/install
if-no-files-found: error
name: build-runtime-${{matrix.config.name}}
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { name: riscv64-linux, shell: bash, arch: riscv64, toolchain: riscv64-unknown-linux, toolchain_env: RISCV_ROOT_PATH, toolchain_file: riscv64-unknown-linux-gnu-12.0.1, qemu: qemu-riscv64, loader_args: '-cpu;rv64,v=true,Zfh=true,vlen=128,elen=64,vext_spec=v1.0;-L', cmakeArgs: '', buildType: Release }

steps:
- uses: actions/checkout@v3
- uses: seanmiddleditch/gha-setup-ninja@master

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

- name: Install toolchain and QEMU
shell: bash
run: |
wget https://dav.sunnycase.moe/d/ci/nncase/${{matrix.config.toolchain_file}}.tar.xz -O toolchain.tar.xz
sudo tar xf toolchain.tar.xz -C $GITHUB_WORKSPACE
echo "${{matrix.config.toolchain_env}}=$GITHUB_WORKSPACE/${{matrix.config.toolchain_file}}" >> $GITHUB_ENV
wget https://dav.sunnycase.moe/d/ci/nncase/${{matrix.config.qemu}}.tgz -O qemu.tgz
sudo tar xf qemu.tgz -C /usr/local/bin
echo "TESTS_EXECUTABLE_LOADER=${{matrix.config.qemu}}" >> $GITHUB_ENV
echo "TESTS_EXECUTABLE_LOADER_ARGUMENTS=${{matrix.config.loader_args}};$GITHUB_WORKSPACE/${{matrix.config.toolchain_file}}/sysroot" >> $GITHUB_ENV
- name: Install Conan
run: |
pip install conan==1.58
conan remote add -i 0 sunnycase https://conan.sunnycase.moe
- name: Configure Conan
run: |
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan config init
sed -i 's/xtensalx7]/xtensalx7, ${{matrix.config.arch}}]/g' ~/.conan/settings.yml
- name: Configure CMake
run: |
conan install . -if build --build=missing -s build_type=${{matrix.config.buildType}} --profile:host=toolchains/riscv64-unknown-linux.profile.jinja --profile:build=default -o runtime=True -o python=False -o tests=True -s compiler.cppstd=17
- name: Build & Install
run: |
conan build . -if build -bf build
cmake --install build --prefix install
- name: Test
shell: bash
run: |
cd build
ctest --test-dir tests/kernels --output-on-failure -j4
- name: Upload nncaseruntime Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncaseruntime-${{matrix.config.name}}
path: ${{github.workspace}}/install
if-no-files-found: error
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ artifacts/
*.pidb
*.svclog
*.scc

*.bin
# Chutzpah Test files
_Chutzpah*

Expand Down Expand Up @@ -306,4 +306,4 @@ cmake-build-*
*gmodel_dump_dir*
*.ipynb_checkpoints*
# Auto generated files
# generated/
# generated/
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ endif()

if(NOT DEFINED NNCASE_VERSION_SUFFIX)
find_package (Git)

execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always --dirty --tag
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Expand Down Expand Up @@ -274,5 +273,5 @@ if(BUILD_TESTING)
endif()

# Modules
#add_subdirectory(modules/k210)

#add_subdirectory(modules/vulkan)
14 changes: 12 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="11.0.2"/>
<PackageVersion Include="Avalonia.Desktop" Version="11.0.2"/>
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.2"/>
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.0.2"/>
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.0.2"/>
<PackageVersion Include="MessageBox.Avalonia" Version="3.1.2" />

<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageVersion Include="Google.OrTools" Version="9.4.1874" />
<PackageVersion Include="AnyTensorFlow.NET" Version="0.70.1" />
<PackageVersion Include="BitFields" Version="0.1.0" />
Expand Down Expand Up @@ -46,11 +54,13 @@
<PackageVersion Include="NetFabric.Hyperlinq" Version="3.0.0-beta48" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Nncase.FlatBuffers" Version="2.0.0" />
<PackageVersion Include="NumSharp" Version="0.30.0" />
<PackageVersion Include="OrtKISharp" Version="0.0.2" />
<PackageVersion Include="RazorLight" Version="2.3.0" />
<PackageVersion Include="Singulink.Collections.Weak" Version="1.0.2" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.507" />
<PackageVersion Include="System.CommandLine.Hosting" Version="0.3.0-alpha.21216.1" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.435" />
<PackageVersion Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Reactive" Version="5.0.0" />
<PackageVersion Include="Tomlyn.Extensions.Configuration" Version="1.0.5" />
Expand Down
4 changes: 4 additions & 0 deletions docs/MixQuant.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ compiler.use_ptq(ptq_options)

```python
ptq_options.quant_scheme = ""
ptq_options.quant_scheme_strict_mode = False
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`

Expand All @@ -36,6 +38,7 @@ compile_options.dump_ir = True

```python
ptq_options.quant_scheme = ""
ptq_options.quant_scheme_strict_mode = False
ptq_options.export_quant_scheme = True
ptq_options.export_weight_range_by_channel = True
```
Expand Down Expand Up @@ -108,6 +111,7 @@ ptq_options.export_weight_range_by_channel = True

```python
ptq_options.quant_scheme = "./QuantScheme.json" # path to your 'QuantScheme.json'
ptq_options.quant_scheme_strict_mode = False # Whether to strictly follow quant_scheme for quantification
ptq_options.export_quant_scheme = False
ptq_options.export_weight_range_by_channel = False # whatever
```
Expand Down
1 change: 1 addition & 0 deletions docs/USAGE_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ PTQTensorOptions类, 用于配置nncase PTQ选项,各属性说明如下
| dump_quant_error | bool || 是否生成量化损失,默认为False。在 `dump_ir=True`时生效 |
| dump_quant_error_symmetric_for_signed | bool || 是否生成使用范围对称的量化损失,默认为True。在 `dump_ir=True`时生效 |
| quant_scheme | string || 量化配置文件路径,默认为“ ”。在 `dump_ir=True`时生效 |
| quant_scheme_strict_mode | bool || 是否严格按照quant_scheme执行量化,默认为False。在 `quant_scheme`不为空时生效 |
| export_quant_scheme | bool || 是否导出量化配置文件,默认为False。在 `dump_ir=True`时生效 |
| export_weight_range_by_channel | bool || 导出量化配置文件时,是否按照channel统计权重的范围,默认为False。在 `dump_ir=True`时生效 |

Expand Down
1 change: 1 addition & 0 deletions docs/USAGE_v2_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ PTQTensorOptions is used to configure PTQ options. The details of all attributes
| dump_quant_error | bool | N | Specify whether dump quantification error, False by default. The parameters following worked when `dump_ir=True`. |
| dump_quant_error_symmetric_for_signed | bool | N | Specify whether dump quantification error by symmetric for signed number,True by default. |
| quant_scheme | string | N | specify the path of quantification scheme file,"" by default. |
| quant_scheme_strict_mode | bool | N | Specify whether strictly follow quant_scheme for quantification, False by default. |
| export_quant_scheme | bool | N | Specify whether export quantification scheme, False by default. |
| export_weight_range_by_channel | bool | N | Specify whether export weights range by channel, False by default. |

Expand Down
Loading

0 comments on commit 359e6d4

Please sign in to comment.