Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNNX is an open standard for PyTorch model interoperability #3262

Merged
merged 173 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
da7861b
Create README.md
nihui Aug 15, 2021
7911531
Add files via upload
nihui Aug 15, 2021
468b08e
Update README.md
nihui Aug 15, 2021
cea0424
Update README.md
nihui Aug 20, 2021
a2a4c86
Update README.md
nihui Aug 22, 2021
207c0ee
Update README.md
nihui Aug 26, 2021
4afd797
Update README.md
nihui Sep 1, 2021
c854c84
Update README.md
nihui Sep 1, 2021
194faad
Update README.md
nihui Sep 1, 2021
a43e5f5
Update README.md
nihui Sep 2, 2021
504891f
Update README.md
nihui Sep 2, 2021
a666912
Update README.md
nihui Sep 2, 2021
e7a0a1e
Update README.md
nihui Sep 2, 2021
800bc73
Update README.md
nihui Sep 2, 2021
c8e088f
Update README.md
nihui Sep 2, 2021
bb70b67
Update README.md
nihui Sep 3, 2021
81dfa27
Update README.md
nihui Sep 3, 2021
7f30d74
Update README.md
nihui Sep 3, 2021
ed41103
Update README.md
nihui Sep 3, 2021
199a8c1
Update README.md
nihui Sep 3, 2021
debffe0
Update README.md
nihui Sep 3, 2021
812074d
Update README.md
nihui Sep 3, 2021
7f4f2cf
Add files via upload
nihui Sep 5, 2021
57e7b07
Update README.md
nihui Sep 5, 2021
1cc29d6
Update README.md
nihui Sep 5, 2021
f042fc2
Add files via upload
nihui Sep 5, 2021
690628c
Update README.md
nihui Sep 5, 2021
77559f7
Add files via upload
nihui Sep 5, 2021
f3d0ee8
Update README.md
nihui Sep 5, 2021
d94fccf
Add files via upload
nihui Sep 5, 2021
a6ca2f5
Update README.md
nihui Sep 5, 2021
ac2b5ad
Update README.md
nihui Sep 5, 2021
5f7a30e
Update README.md
nihui Sep 5, 2021
b1fd702
Add files via upload
nihui Sep 8, 2021
3413e30
Update README.md
nihui Sep 8, 2021
262e2b4
Add files via upload
nihui Sep 8, 2021
639b87c
Add files via upload
nihui Sep 8, 2021
8f53f1a
Update README.md
nihui Sep 8, 2021
72f329a
Add files via upload
nihui Sep 8, 2021
5aa9704
Update README.md
nihui Sep 8, 2021
95df371
Update README.md
nihui Sep 13, 2021
085d3cb
Update README.md
nihui Sep 15, 2021
d62c8dd
Update README.md
nihui Sep 22, 2021
4474bec
Update README.md
nihui Sep 22, 2021
1aa8beb
Update README.md
nihui Sep 23, 2021
b70fec3
Update README.md
nihui Sep 24, 2021
a899289
the initial pnnx source
nihui Oct 1, 2021
4f4b2d0
apply code-format changes
nihui Oct 1, 2021
6191858
Update README.md
nihui Oct 1, 2021
be584a0
Merge branch 'Tencent:master' into pnnx
nihui Oct 1, 2021
3519610
Update README.md
nihui Oct 1, 2021
77910de
convert pnnx input and output
nihui Oct 2, 2021
12d7f32
Merge branch 'pnnx' of https://github.com/nihui/ncnn into pnnx
nihui Oct 2, 2021
422b134
dynamic shape propagation
nihui Oct 3, 2021
1c6e5aa
Merge branch 'Tencent:master' into pnnx
nihui Oct 8, 2021
349bbf9
update
nihui Oct 11, 2021
b11b690
update
nihui Oct 11, 2021
67aaf32
update
nihui Oct 11, 2021
35b3e29
fix rnn tests
nihui Oct 12, 2021
e6cc01a
rnn stubs
nihui Oct 12, 2021
d1294fc
convert to ncnn custom op
nihui Oct 13, 2021
63b4c5f
apply code-format changes
nihui Oct 13, 2021
e69058e
pre-eval attribute pass
nihui Oct 13, 2021
49acd6e
numbered expr op name
nihui Oct 13, 2021
550bade
handle unsupported ncnn expr, output verbose unsupported param
nihui Oct 13, 2021
c2687e9
fix ncnn pooling ceil_mode
nihui Oct 15, 2021
376b650
fix ncnn normalize scale data, fuse linear bn
nihui Oct 15, 2021
35e1b28
wip
nihui Oct 15, 2021
5ce9a1f
fix build
nihui Oct 22, 2021
93f36fc
fix ncnn deconv weight order
nihui Oct 25, 2021
bf9819c
fix deconv bn fusion, add unit tests for conv-bn and deconv-bn fusion
nihui Oct 25, 2021
4bd2754
fix conv-bn fusion
nihui Oct 26, 2021
abbbe29
unroll multi-layer rnn ops
nihui Oct 26, 2021
d2c3a3c
use c++14
nihui Oct 26, 2021
45c2c08
convert ncnn rnn/lstm/gru
nihui Oct 27, 2021
101cf62
update
nihui Oct 27, 2021
a02698e
test for linear-bn fusion
nihui Oct 27, 2021
c0f8f89
optional torchvision
nihui Oct 27, 2021
162a910
torch 1.8 fix
nihui Oct 28, 2021
af41142
torch 1.8 fix
nihui Oct 28, 2021
fa8dc0f
torch 1.10 fix
nihui Oct 28, 2021
89c3b06
pnnx coverage
nihui Oct 29, 2021
6c06d2e
end2end quantization model test
nihui Oct 29, 2021
4663efd
apply code-format changes
nihui Nov 1, 2021
b88b9d4
qat wip
nihui Nov 1, 2021
57f455d
temp fix for tensortype const
nihui Nov 1, 2021
1f5e352
Merge branch 'pnnx' of github.com:nihui/ncnn into pnnx
nihui Nov 1, 2021
2251345
apply code-format changes
nihui Nov 1, 2021
bbaff92
torch split
nihui Nov 1, 2021
358cdf1
apply code-format changes
nihui Nov 1, 2021
0a4b311
ncnn upsample scale_factor
nihui Nov 1, 2021
c990184
more generic cat chunk split conversion, fix bool param pattern
nihui Nov 2, 2021
0d04319
fuse sigmoid + mul to silu
nihui Nov 2, 2021
a2fd96e
some ncnn optimize pass, add mobilenet_v3 test
nihui Nov 2, 2021
5272ddb
ncnn eliminate dropout
nihui Nov 2, 2021
e7ca7eb
ncnn eliminate generic noop
nihui Nov 2, 2021
bef70d4
ncnn chain multi output
nihui Nov 3, 2021
c7033d1
apply code-format changes
nihui Nov 3, 2021
bc3e613
fix ncnn reshape view dynamic size
nihui Nov 3, 2021
1cbd1d6
Merge branch 'Tencent:master' into pnnx
nihui Nov 3, 2021
cb7a816
fix ncnn cat chunk split axis
nihui Nov 3, 2021
c2259f2
yet another fix try
nihui Nov 3, 2021
0636d72
major graph rewritter api changes
nihui Nov 3, 2021
b466299
convert ncnn memorydata, fix norm affine param
nihui Nov 3, 2021
9d2227e
solve all batch index for ncnn conversion
nihui Nov 3, 2021
6b24c89
honor batch index in reshape slice view cat chunk split permute trans…
nihui Nov 4, 2021
51e7c50
Merge branch 'Tencent:master' into pnnx
nihui Nov 4, 2021
3c6ba51
canonicalize ncnn input and output blob name
nihui Nov 5, 2021
8ba9f33
no more underscore makes life easier
nihui Nov 5, 2021
9621d72
Merge branch 'Tencent:master' into pnnx
nihui Nov 5, 2021
5b9e452
add pnnx2ncnn test
nihui Nov 5, 2021
43d98f0
end2end pnnx2ncnn test
nihui Nov 5, 2021
68d4c27
fix ncnn batchnorm affine
nihui Nov 6, 2021
1dbe6ef
ncnn multiheadattention test
nihui Nov 6, 2021
7e16dd4
ncnn channelshuffle test
nihui Nov 6, 2021
2dcd5d4
pnnx neg expression
nihui Nov 7, 2021
dcba98e
ncnn rnn/lstm/gru test
nihui Nov 8, 2021
20633a6
apply code-format changes
nihui Nov 8, 2021
77a946f
fix pytorch 1.8 test
nihui Nov 8, 2021
c09e770
ncnn permute noop
nihui Nov 8, 2021
a96e6c8
Merge branch 'Tencent:master' into pnnx
nihui Nov 8, 2021
d5d680c
ncnn adaptiveavgpool2d softmax test
nihui Nov 8, 2021
a83a5bd
ncnn pad2d leakyrelu prelu test
nihui Nov 8, 2021
a72a82e
more rules for silu hardsigmoid hardswish mish, add clamp
nihui Nov 9, 2021
93fdc95
add nn.Embedding
nihui Nov 9, 2021
61afb2e
canonicalize input layer name
nihui Nov 9, 2021
4874ba6
fix ncnn hsigmoid hswish params
nihui Nov 9, 2021
e82190a
ncnn hardsigmoid hardswish test
nihui Nov 9, 2021
55c032f
Merge branch 'Tencent:master' into pnnx
nihui Nov 10, 2021
b1365fc
try windows build
nihui Nov 10, 2021
90dc809
fix msvc build
nihui Nov 10, 2021
3e7723b
fix forward type
nihui Nov 10, 2021
fae7935
portable packed structure
nihui Nov 10, 2021
fd46e0f
apply code-format changes
nihui Nov 10, 2021
8b2de2a
explicit parameter construction
nihui Nov 10, 2021
dd22e00
style changes
nihui Nov 10, 2021
3db1f3c
use int64_t overload
nihui Nov 10, 2021
4af4428
Merge branch 'Tencent:master' into pnnx
nihui Nov 10, 2021
845b061
tensor.item<int64_t>
nihui Nov 10, 2021
3e96b46
set rpath
nihui Nov 10, 2021
2e59b80
more ncnn tests
nihui Nov 11, 2021
2253287
more ncnn tests
nihui Nov 11, 2021
b66c0e5
Merge branch 'Tencent:master' into pnnx
nihui Nov 11, 2021
7be886c
Merge branch 'Tencent:master' into pnnx
nihui Nov 12, 2021
a7e107b
ncnn upsample test
nihui Nov 12, 2021
0a74bde
more ncnn tests
nihui Nov 12, 2021
60c5906
ncnn upsample interpolate test
nihui Nov 12, 2021
975b5eb
more test
nihui Nov 12, 2021
4a843da
Merge branch 'Tencent:master' into pnnx
nihui Nov 12, 2021
3566073
number order
nihui Nov 13, 2021
2faa2a2
apply code-format changes
nihui Nov 13, 2021
696c012
fix memory leak
nihui Nov 13, 2021
9acea91
apply code-format changes
nihui Nov 13, 2021
fa8b15a
fix ncnn slice end -1
nihui Nov 15, 2021
c057326
more ncnn tests
nihui Nov 15, 2021
dca0a9d
ncnn interp-1d
nihui Nov 15, 2021
3fbc433
Merge branch 'Tencent:master' into pnnx
nihui Nov 15, 2021
a9dc973
Merge branch 'Tencent:master' into pnnx
nihui Nov 16, 2021
e23650f
update rnn test
nihui Nov 16, 2021
380ae01
Merge branch 'Tencent:master' into pnnx
nihui Nov 16, 2021
17488d3
Update pass_level2.cpp (#29)
xiaooquanwu Nov 17, 2021
ffc0f4a
ncnn squeeze expanddims, handle reshape across batch axis
nihui Nov 17, 2021
9a57d70
Merge branch 'Tencent:master' into pnnx
nihui Nov 17, 2021
654d847
fuse ncnn conv2d activation
nihui Nov 17, 2021
0572bb3
Merge branch 'Tencent:master' into pnnx
nihui Nov 22, 2021
5546457
Merge branch 'Tencent:master' into pnnx
nihui Nov 22, 2021
fc1a901
code clean
nihui Nov 22, 2021
ab425fe
do not trigger ncnn ci for pnnx changes
nihui Nov 22, 2021
4a6ec98
add pnnx ci
nihui Nov 22, 2021
f72f2a3
fix warnings
nihui Nov 22, 2021
7679005
move assets to ncnn-assets
nihui Nov 22, 2021
f37a0a4
update readme
nihui Nov 22, 2021
57fe8cd
do not trigger ci on doc changes
nihui Nov 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/linux-x64-cpu-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
linux-clang:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linux-x64-cpu-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
linux-gcc:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linux-x64-gpu-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
linux-clang-gpu:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linux-x64-gpu-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
linux-gcc-gpu:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos-x64-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -23,6 +24,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos-x64-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/pnnx.yml
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
2 changes: 2 additions & 0 deletions .github/workflows/windows-x64-cpu-vs2015.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -23,6 +24,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
windows-vs2015:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows-x64-cpu-vs2017.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -23,6 +24,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
windows-vs2017:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows-x64-cpu-vs2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -23,6 +24,7 @@ on:
- 'src/layer/x86/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
windows-vs2019:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows-x64-gpu-vs2017.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
windows-vs2017-gpu:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows-x64-gpu-vs2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
pull_request:
branches: [master]
Expand All @@ -25,6 +26,7 @@ on:
- 'src/layer/vulkan/**'
- 'tests/**'
- 'tools/**'
- '!tools/pnnx/**'
- 'examples/**'
jobs:
windows-vs2019-gpu:
Expand Down
44 changes: 44 additions & 0 deletions tools/pnnx/CMakeLists.txt
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)
Loading