9
- '!tools/pnnx/README.md'
11
target-branches: [master]
16
- '!tools/pnnx/README.md'
18
group: pnnx-${{ ci.head_ref }}
21
protobuf_version: 21.12
22
libtorch_version: 2.4.0
23
libtorchvision_version: 0.19.0
24
onnxruntime_version: 1.18.1
32
- torch-version: 1.8.1
33
torchvision-version: 0.9.1
35
- torch-version: 1.9.1
36
torchvision-version: 0.10.1
38
- torch-version: 1.10.0
39
torchvision-version: 0.11.1
41
- torch-version: 1.11.0
42
torchvision-version: 0.12.0
44
- torch-version: 1.12.0
45
torchvision-version: 0.13.0
47
- torch-version: 1.13.0
48
torchvision-version: 0.14.0
50
- torch-version: 2.0.0
51
torchvision-version: 0.15.1
53
- torch-version: 2.1.0
54
torchvision-version: 0.16.0
56
- torch-version: 2.2.1
57
torchvision-version: 0.17.1
59
- torch-version: 2.3.0
60
torchvision-version: 0.18.0
62
- torch-version: 2.4.0
63
torchvision-version: 0.19.0
73
strategy: FRESH_CHECKOUT
79
apt-get install -y python3-pip libjpeg-dev libpng-dev
80
python3 -m pip install --upgrade pip
81
apt-get remove -y python3-setuptools
82
pip3 install -U setuptools==69.5.1
83
pip3 install -U pytest wheel twine requests einops numpy==1.26.4
85
wget -q https://github.com/Kitware/CMake/releases/download/v3.29.3/cmake-3.29.3-linux-x86_64.tar.gz
86
tar -xf cmake-3.29.3-linux-x86_64.tar.gz
88
- name: cache-pnnx-deps-torch
89
id: cache-pnnx-deps-torch
92
cachePaths: pnnx-deps-torch-install
93
cacheKey: pnnx-deps-torch-linux-install-${{variables.cache_date}}
95
- name: cache-pnnx-deps-onnx
96
id: cache-pnnx-deps-onnx
99
cachePaths: pnnx-deps-onnx-install
100
cacheKey: pnnx-deps-onnx-linux-install-${{variables.cache_date}}
102
- name: checkout-pnnx-patches
103
if: steps.cache-pnnx-deps-torch.outputs.cacheHit != 'true' || steps.cache-pnnx-deps-onnx.outputs.cacheHit != 'true'
104
checkout: https://github.com/pnnx/pnnx.git
107
localPath: pnnx-patches
108
enableSubmodule: false
111
- name: pnnx-deps-torch-libtorch
112
if: steps.cache-pnnx-deps-torch.outputs.cacheHit != 'true'
114
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
115
wget -q https://github.com/pytorch/pytorch/releases/download/v${{variables.libtorch_version}}/pytorch-v${{variables.libtorch_version}}.tar.gz
116
tar -xf pytorch-v${{variables.libtorch_version}}.tar.gz
117
cd pytorch-v${{variables.libtorch_version}}
118
pip3 install -r requirements.txt
119
patch -p1 -i ${{ci.workspace}}/pnnx-patches/pytorch-v${{variables.libtorch_version}}-fix-mobile-build.patch
120
patch -p1 -i ${{ci.workspace}}/pnnx-patches/pytorch-v${{variables.libtorch_version}}-no-link-system-lib.patch
121
patch -p1 -i ${{ci.workspace}}/pnnx-patches/pytorch-v${{variables.libtorch_version}}-fix-pocketfft-build.patch
122
mkdir -p build && cd build
123
cmake -DCMAKE_INSTALL_PREFIX=${{ci.workspace}}/pnnx-deps-torch-install -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SHARED_LIBS=OFF -DBUILD_CAFFE2_OPS=OFF -DBUILD_CUSTOM_PROTOBUF=OFF -DBUILD_LITE_INTERPRETER=OFF -DBUILD_PYTHON=OFF -DINTERN_BUILD_MOBILE=ON -DINTERN_DISABLE_AUTOGRAD=ON -DINTERN_DISABLE_ONNX=ON -DUSE_CUDA=OFF -DUSE_DISTRIBUTED=OFF -DUSE_ITT=OFF -DUSE_KINETO=OFF -DUSE_LITE_INTERPRETER_PROFILER=OFF -DUSE_MKLDNN=OFF -DUSE_MPS=OFF -DUSE_NUMPY=OFF -DUSE_OPENMP=OFF -DUSE_SOURCE_DEBUG_ON_MOBILE=OFF -DUSE_XNNPACK=OFF ..
124
cmake --build . -j $(nproc)
125
cmake --build . -j $(nproc) --target install/strip
126
- name: pnnx-deps-torch-libtorchvision
127
if: steps.cache-pnnx-deps-torch.outputs.cacheHit != 'true'
129
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
130
wget -q https://github.com/pytorch/vision/archive/v${{variables.libtorchvision_version}}.zip -O vision-${{variables.libtorchvision_version}}.zip
131
unzip -q vision-${{variables.libtorchvision_version}}.zip
132
cd vision-${{variables.libtorchvision_version}}
133
patch -p1 -i ${{ci.workspace}}/pnnx-patches/vision-${{variables.libtorchvision_version}}-ops-only.patch
134
patch -p1 -i ${{ci.workspace}}/pnnx-patches/vision-${{variables.libtorchvision_version}}-no-cuda-version.patch
135
mkdir -p build && cd build
136
cmake -DCMAKE_INSTALL_PREFIX=${{ci.workspace}}/pnnx-deps-torch-install -DTorch_DIR=${{ci.workspace}}/pnnx-deps-torch-install/share/cmake/Torch -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_PNG=OFF -DWITH_JPEG=OFF ..
137
cmake --build . -j $(nproc)
138
cmake --build . -j $(nproc) --target install/strip
140
- name: pnnx-deps-onnx-protobuf
141
if: steps.cache-pnnx-deps-onnx.outputs.cacheHit != 'true'
143
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
144
wget -q https://github.com/protocolbuffers/protobuf/archive/v${{variables.protobuf_version}}.zip -O protobuf-${{variables.protobuf_version}}.zip
145
unzip -q protobuf-${{variables.protobuf_version}}.zip
146
cd protobuf-${{variables.protobuf_version}}
147
mkdir -p build2 && cd build2
148
cmake -DCMAKE_INSTALL_PREFIX=${{ci.workspace}}/pnnx-deps-onnx-install -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
149
cmake --build . -j $(nproc)
150
cmake --build . --target install/strip
151
- name: pnnx-deps-onnx-onnxruntime
152
if: steps.cache-pnnx-deps-onnx.outputs.cacheHit != 'true'
154
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
155
wget -q https://github.com/microsoft/onnxruntime/archive/v${{variables.onnxruntime_version}}.zip -O onnxruntime-${{variables.onnxruntime_version}}.zip
156
unzip -q onnxruntime-${{variables.onnxruntime_version}}.zip
157
cd onnxruntime-${{variables.onnxruntime_version}}
158
patch -p1 -i ${{ci.workspace}}/pnnx-patches/onnxruntime-${{variables.onnxruntime_version}}-less-mlas-features.patch
159
patch -p1 -i ${{ci.workspace}}/pnnx-patches/onnxruntime-${{variables.onnxruntime_version}}-monolithic-static-library.patch
160
mkdir -p build && cd build
161
cmake -DCMAKE_INSTALL_PREFIX=${{ci.workspace}}/pnnx-deps-onnx-install -DCMAKE_BUILD_TYPE=MinSizeRel -Donnxruntime_USE_FULL_PROTOBUF=ON -Donnxruntime_BUILD_SHARED_LIB=ON -Donnxruntime_BUILD_UNIT_TESTS=OFF -Donnxruntime_ENABLE_CPUINFO=OFF -Donnxruntime_DISABLE_CONTRIB_OPS=ON -Donnxruntime_DISABLE_ML_OPS=ON -Donnxruntime_DISABLE_SPARSE_TENSORS=ON --compile-no-warning-as-error ../cmake
162
cmake --build . -j $(nproc)
163
cmake --build . -j $(nproc) --target install/strip
165
- name: setup-pytorch
167
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
168
pip3 install --user torch==${{matrix.torch-version}}+cpu torchvision==${{matrix.torchvision-version}}+cpu --index-url https://download.pytorch.org/whl/cpu
169
pip3 install --user onnx
170
pip3 install --user onnxscript
174
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
175
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
176
mkdir build && cd build
177
cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_PYTHON=ON -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF ..
178
cmake --build . -j 16
180
export CMAKE_BUILD_PARALLEL_LEVEL=16
181
pip3 install --user .
185
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
186
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
188
mkdir build && cd build
189
cmake -DCMAKE_BUILD_TYPE=Release -DTorch_INSTALL_DIR=${{ci.workspace}}/pnnx-deps-torch-install -DTorchVision_INSTALL_DIR=${{ci.workspace}}/pnnx-deps-torch-install -Donnxruntime_INSTALL_DIR=${{ci.workspace}}/pnnx-deps-onnx-install -Dprotobuf_DIR=${{ci.workspace}}/pnnx-deps-onnx-install/lib/cmake/protobuf ..
190
cmake --build . -j 16 --verbose
194
export PATH=${{ci.workspace}}/cmake-3.29.3-linux-x86_64/bin:$PATH
195
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
196
export OMP_NUM_THREADS=1
197
export MKL_NUM_THREADS=1
198
export MKL_ENABLE_INSTRUCTIONS=SSE4_2
200
cd build && ctest --output-on-failure -j 16
204
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
205
export PNNX_WHEEL_WITHOUT_BUILD=ON
207
cp ../build/src/pnnx pnnx/
208
python3 setup.py install --user