-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PNNX is an open standard for PyTorch model interoperability (#3262)
Co-authored-by: nihui <[email protected]> Co-authored-by: xiaooquanwu <[email protected]>
- Loading branch information
1 parent
3644ded
commit e4c821a
Showing
622 changed files
with
47,662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: pnnx | ||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- '.github/workflows/pnnx.yml' | ||
- 'tools/pnnx/**' | ||
- '!tools/pnnx/README.md' | ||
pull_request: | ||
branches: [master] | ||
paths: | ||
- '.github/workflows/pnnx.yml' | ||
- 'tools/pnnx/**' | ||
- '!tools/pnnx/README.md' | ||
jobs: | ||
ubuntu: | ||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- torch-version: 1.8.1 | ||
torchvision-version: 0.9.1 | ||
|
||
- torch-version: 1.9.1 | ||
torchvision-version: 0.10.1 | ||
|
||
- torch-version: 1.10.0 | ||
torchvision-version: 0.11.1 | ||
|
||
steps: | ||
- name: cancel-previous-runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: setup pytorch-${{ matrix.torch-version }} | ||
run: | | ||
pip install torch==${{ matrix.torch-version }}+cpu torchvision==${{ matrix.torchvision-version }}+cpu -f https://download.pytorch.org/whl/torch_stable.html | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: build-ncnn | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest setuptools wheel twine | ||
mkdir build && cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_PYTHON=ON -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | ||
cmake --build . -j 2 | ||
cd .. | ||
pip install . | ||
- name: build-pnnx | ||
run: | | ||
cd tools/pnnx | ||
mkdir build && cd build | ||
cmake -DTorch_INSTALL_DIR="$HOME/.local/lib/python3.8/site-packages/torch" -DCMAKE_BUILD_TYPE=Release .. | ||
cmake --build . -j 2 | ||
- name: test | ||
run: | | ||
cd tools/pnnx | ||
cd build && ctest --output-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
project(pnnx) | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# c++14 is required for using torch headers | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
#set(CMAKE_BUILD_TYPE debug) | ||
#set(CMAKE_BUILD_TYPE relwithdebinfo) | ||
#set(CMAKE_BUILD_TYPE release) | ||
|
||
option(PNNX_COVERAGE "build for coverage" OFF) | ||
|
||
#set(Torch_INSTALL_DIR "/home/nihui/.local/lib/python3.9/site-packages/torch" CACHE STRING "") | ||
#set(Torch_INSTALL_DIR "/home/nihui/osd/pnnx/pytorch-v1.10.0/build/install" CACHE STRING "") | ||
set(Torch_INSTALL_DIR "/home/nihui/osd/pnnx/libtorch" CACHE STRING "") | ||
set(TorchVision_INSTALL_DIR "/home/nihui/osd/vision/build/install" CACHE STRING "") | ||
|
||
set(Torch_DIR "${Torch_INSTALL_DIR}/share/cmake/Torch") | ||
set(TorchVision_DIR "${TorchVision_INSTALL_DIR}/share/cmake/TorchVision") | ||
|
||
find_package(Torch REQUIRED) | ||
find_package(TorchVision QUIET) | ||
|
||
message(STATUS "Torch_VERSION = ${Torch_VERSION}") | ||
message(STATUS "Torch_VERSION_MAJOR = ${Torch_VERSION_MAJOR}") | ||
message(STATUS "Torch_VERSION_MINOR = ${Torch_VERSION_MINOR}") | ||
message(STATUS "Torch_VERSION_PATCH = ${Torch_VERSION_PATCH}") | ||
|
||
if(Torch_VERSION VERSION_LESS "1.8") | ||
message(FATAL_ERROR "pnnx only supports PyTorch >= 1.8") | ||
endif() | ||
|
||
if(TorchVision_FOUND) | ||
message(STATUS "Building with TorchVision") | ||
else() | ||
message(WARNING "Building without TorchVision") | ||
endif() | ||
|
||
include_directories(${TORCH_INCLUDE_DIRS}) | ||
|
||
add_subdirectory(src) | ||
|
||
enable_testing() | ||
add_subdirectory(tests) |
Oops, something went wrong.