rapidocr-ng 5.0.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rapidocr_ng-5.0.0a1/.github/check_manylinux_tag.sh +25 -0
- rapidocr_ng-5.0.0a1/.github/workflows/build-wheels.yml +229 -0
- rapidocr_ng-5.0.0a1/.github/workflows/vulkan-lavapipe.yml +76 -0
- rapidocr_ng-5.0.0a1/.gitignore +27 -0
- rapidocr_ng-5.0.0a1/.gitmodules +3 -0
- rapidocr_ng-5.0.0a1/CMakeLists.txt +290 -0
- rapidocr_ng-5.0.0a1/PKG-INFO +153 -0
- rapidocr_ng-5.0.0a1/README-CN.md +408 -0
- rapidocr_ng-5.0.0a1/README.md +408 -0
- rapidocr_ng-5.0.0a1/cmake/ppocrConfig.cmake.in +5 -0
- rapidocr_ng-5.0.0a1/docs/API.md +212 -0
- rapidocr_ng-5.0.0a1/docs/PERFORMANCE.md +245 -0
- rapidocr_ng-5.0.0a1/docs/RELEASING.md +69 -0
- rapidocr_ng-5.0.0a1/examples/c_api_demo.c +56 -0
- rapidocr_ng-5.0.0a1/examples/cpp_api_demo.cpp +37 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_batch_smoke.cpp +216 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_bench.cpp +121 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_demo.cpp +46 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_determinism.cpp +143 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_gpu_frontend_smoke.cpp +169 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_gpu_graph_mem_soak.cpp +157 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_gpu_graph_smoke.cpp +146 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_gpu_ocr_smoke.cpp +145 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_gpu_pipeline_smoke.cpp +180 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_isa_bench.cpp +85 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_kernel_smoke.cpp +2068 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_mem_soak.cpp +161 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_vulkan_robust.cpp +241 -0
- rapidocr_ng-5.0.0a1/examples/ppocr_vulkan_smoke.cpp +3571 -0
- rapidocr_ng-5.0.0a1/include/ppocr/export.h +23 -0
- rapidocr_ng-5.0.0a1/include/ppocr/ppocr.h +159 -0
- rapidocr_ng-5.0.0a1/include/ppocr/ppocr.hpp +192 -0
- rapidocr_ng-5.0.0a1/pyproject.toml +74 -0
- rapidocr_ng-5.0.0a1/python/README.md +128 -0
- rapidocr_ng-5.0.0a1/python/demo.py +30 -0
- rapidocr_ng-5.0.0a1/python/pyproject.toml +49 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/__init__.py +35 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/__main__.py +6 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/_native.py +281 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/config.yaml +191 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/default_models.yaml +1557 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/download.py +5 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/inference_engine/__init__.py +10 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/inference_engine/base.py +92 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/main.py +439 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/models/.gitkeep +0 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/output.py +171 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/py.typed +0 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/typings.py +79 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/__init__.py +1 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/download_file.py +111 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/download_models.py +133 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/load_image.py +237 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/log.py +11 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/model_resolver.py +124 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/parse_parameters.py +110 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/process_img.py +85 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/typings.py +23 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/utils.py +20 -0
- rapidocr_ng-5.0.0a1/python/src/rapidocr/utils/vis_res.py +36 -0
- rapidocr_ng-5.0.0a1/python/tests/ci-constraints.txt +6 -0
- rapidocr_ng-5.0.0a1/python/tests/ci_wheel_check.sh +82 -0
- rapidocr_ng-5.0.0a1/python/tests/data/hello.png +0 -0
- rapidocr_ng-5.0.0a1/python/tests/fetch_ci_models.py +75 -0
- rapidocr_ng-5.0.0a1/python/tests/test_api.py +71 -0
- rapidocr_ng-5.0.0a1/python/tests/test_download.py +120 -0
- rapidocr_ng-5.0.0a1/python/tests/test_main_api_sync.py +266 -0
- rapidocr_ng-5.0.0a1/python/tests/test_main_compat.py +300 -0
- rapidocr_ng-5.0.0a1/python/tests/test_vulkan.py +96 -0
- rapidocr_ng-5.0.0a1/python/tools/validate_model_routes.py +107 -0
- rapidocr_ng-5.0.0a1/src/embed_spirv.cmake +39 -0
- rapidocr_ng-5.0.0a1/src/kernels.cpp +6350 -0
- rapidocr_ng-5.0.0a1/src/kernels.hpp +413 -0
- rapidocr_ng-5.0.0a1/src/kernels_avx2.cpp +3401 -0
- rapidocr_ng-5.0.0a1/src/kernels_avx512.cpp +5964 -0
- rapidocr_ng-5.0.0a1/src/onnx_lite.cpp +10266 -0
- rapidocr_ng-5.0.0a1/src/onnx_lite.hpp +173 -0
- rapidocr_ng-5.0.0a1/src/ppocr.cpp +2348 -0
- rapidocr_ng-5.0.0a1/src/ppocr_c_api.cpp +314 -0
- rapidocr_ng-5.0.0a1/src/vulkan_backend.cpp +9289 -0
- rapidocr_ng-5.0.0a1/src/vulkan_backend.hpp +950 -0
- rapidocr_ng-5.0.0a1/src/vulkan_binary.comp +2490 -0
- rapidocr_ng-5.0.0a1/src/vulkan_depthwise_tail.comp +80 -0
- rapidocr_ng-5.0.0a1/src/vulkan_pointwise_tail.comp +48 -0
- rapidocr_ng-5.0.0a1/tests/c_api_smoke.c +52 -0
- rapidocr_ng-5.0.0a1/tests/check_isa_encoding.sh +33 -0
- rapidocr_ng-5.0.0a1/tests/run_vulkan_lavapipe.sh +98 -0
- rapidocr_ng-5.0.0a1/tools/bench_cpu.sh +16 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fail unless every wheel in the directory is a manylinux2014 / manylinux_2_17 wheel.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
dir=${1:-wheelhouse}
|
|
6
|
+
python3 -m pip install -q auditwheel
|
|
7
|
+
mapfile -t wheels < <(find "$dir" -type f -name '*.whl' | sort)
|
|
8
|
+
if [[ ${#wheels[@]} -eq 0 ]]; then
|
|
9
|
+
echo "no wheels under $dir" >&2
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
for wheel in "${wheels[@]}"; do
|
|
13
|
+
base=$(basename "$wheel")
|
|
14
|
+
if ! echo "$base" | grep -Eq 'manylinux2014|manylinux_2_17'; then
|
|
15
|
+
echo "platform tag missing from filename: $base" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
show=$(python3 -m auditwheel show "$wheel")
|
|
19
|
+
printf '%s\n' "$show"
|
|
20
|
+
if ! printf '%s\n' "$show" | grep -Eq 'manylinux2014|manylinux_2_17'; then
|
|
21
|
+
echo "auditwheel show did not report manylinux2014/manylinux_2_17: $base" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
echo "tag_ok $base"
|
|
25
|
+
done
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
name: build wheels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- V5_NG
|
|
7
|
+
tags:
|
|
8
|
+
- "v5*"
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- V5_NG
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: wheels-${{ github.workflow }}-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
sdist:
|
|
23
|
+
name: sdist
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
with:
|
|
28
|
+
submodules: recursive
|
|
29
|
+
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
|
|
34
|
+
- name: Build sdist
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install -U build
|
|
37
|
+
python -m build --sdist
|
|
38
|
+
(cd dist && sha256sum ./*.tar.gz > SHA256SUMS)
|
|
39
|
+
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: rapidocr_ng-sdist
|
|
43
|
+
path: |
|
|
44
|
+
dist/*.tar.gz
|
|
45
|
+
dist/SHA256SUMS
|
|
46
|
+
if-no-files-found: error
|
|
47
|
+
|
|
48
|
+
wheels-x86_64:
|
|
49
|
+
name: wheels x86_64
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
with:
|
|
54
|
+
submodules: recursive
|
|
55
|
+
|
|
56
|
+
- uses: actions/setup-python@v5
|
|
57
|
+
with:
|
|
58
|
+
python-version: "3.12"
|
|
59
|
+
|
|
60
|
+
- name: Cache tiny models
|
|
61
|
+
uses: actions/cache@v4
|
|
62
|
+
with:
|
|
63
|
+
path: ci-models
|
|
64
|
+
key: rapidocr-ci-models-tiny-v1
|
|
65
|
+
|
|
66
|
+
- name: Download tiny models when the cache is empty
|
|
67
|
+
run: python python/tests/fetch_ci_models.py
|
|
68
|
+
|
|
69
|
+
- name: Build manylinux2014 wheels
|
|
70
|
+
uses: pypa/cibuildwheel@v2.23.3
|
|
71
|
+
env:
|
|
72
|
+
CIBW_ARCHS: x86_64
|
|
73
|
+
|
|
74
|
+
- name: Check manylinux2014 / manylinux_2_17 tags
|
|
75
|
+
run: bash .github/check_manylinux_tag.sh wheelhouse
|
|
76
|
+
|
|
77
|
+
- uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: rapidocr_ng-wheels-x86_64
|
|
80
|
+
path: wheelhouse/*.whl
|
|
81
|
+
if-no-files-found: error
|
|
82
|
+
|
|
83
|
+
wheels-aarch64:
|
|
84
|
+
name: wheels aarch64
|
|
85
|
+
runs-on: ubuntu-24.04-arm
|
|
86
|
+
outputs:
|
|
87
|
+
started: ${{ steps.mark.outputs.started }}
|
|
88
|
+
steps:
|
|
89
|
+
- name: Mark the native ARM runner as available
|
|
90
|
+
id: mark
|
|
91
|
+
run: echo "started=true" >> "$GITHUB_OUTPUT"
|
|
92
|
+
|
|
93
|
+
- uses: actions/checkout@v4
|
|
94
|
+
with:
|
|
95
|
+
submodules: recursive
|
|
96
|
+
|
|
97
|
+
- uses: actions/setup-python@v5
|
|
98
|
+
with:
|
|
99
|
+
python-version: "3.12"
|
|
100
|
+
|
|
101
|
+
- name: Cache tiny models
|
|
102
|
+
uses: actions/cache@v4
|
|
103
|
+
with:
|
|
104
|
+
path: ci-models
|
|
105
|
+
key: rapidocr-ci-models-tiny-v1
|
|
106
|
+
|
|
107
|
+
- name: Download tiny models when the cache is empty
|
|
108
|
+
run: python python/tests/fetch_ci_models.py
|
|
109
|
+
|
|
110
|
+
- name: Build manylinux2014 wheels
|
|
111
|
+
uses: pypa/cibuildwheel@v2.23.3
|
|
112
|
+
env:
|
|
113
|
+
CIBW_ARCHS: aarch64
|
|
114
|
+
|
|
115
|
+
- name: Check manylinux2014 / manylinux_2_17 tags
|
|
116
|
+
run: bash .github/check_manylinux_tag.sh wheelhouse
|
|
117
|
+
|
|
118
|
+
- uses: actions/upload-artifact@v4
|
|
119
|
+
with:
|
|
120
|
+
name: rapidocr_ng-wheels-aarch64
|
|
121
|
+
path: wheelhouse/*.whl
|
|
122
|
+
if-no-files-found: error
|
|
123
|
+
|
|
124
|
+
wheels-aarch64-qemu:
|
|
125
|
+
name: wheels aarch64 qemu
|
|
126
|
+
needs: wheels-aarch64
|
|
127
|
+
if: >-
|
|
128
|
+
always() &&
|
|
129
|
+
needs.wheels-aarch64.result == 'failure' &&
|
|
130
|
+
needs.wheels-aarch64.outputs.started != 'true'
|
|
131
|
+
runs-on: ubuntu-latest
|
|
132
|
+
steps:
|
|
133
|
+
- uses: actions/checkout@v4
|
|
134
|
+
with:
|
|
135
|
+
submodules: recursive
|
|
136
|
+
|
|
137
|
+
- uses: actions/setup-python@v5
|
|
138
|
+
with:
|
|
139
|
+
python-version: "3.12"
|
|
140
|
+
|
|
141
|
+
- name: QEMU for aarch64
|
|
142
|
+
uses: docker/setup-qemu-action@v3
|
|
143
|
+
with:
|
|
144
|
+
platforms: arm64
|
|
145
|
+
|
|
146
|
+
- name: Cache tiny models
|
|
147
|
+
uses: actions/cache@v4
|
|
148
|
+
with:
|
|
149
|
+
path: ci-models
|
|
150
|
+
key: rapidocr-ci-models-tiny-v1
|
|
151
|
+
|
|
152
|
+
- name: Download tiny models when the cache is empty
|
|
153
|
+
run: python python/tests/fetch_ci_models.py
|
|
154
|
+
|
|
155
|
+
- name: Build manylinux2014 wheels
|
|
156
|
+
uses: pypa/cibuildwheel@v2.23.3
|
|
157
|
+
env:
|
|
158
|
+
CIBW_ARCHS: aarch64
|
|
159
|
+
|
|
160
|
+
- name: Check manylinux2014 / manylinux_2_17 tags
|
|
161
|
+
run: bash .github/check_manylinux_tag.sh wheelhouse
|
|
162
|
+
|
|
163
|
+
- uses: actions/upload-artifact@v4
|
|
164
|
+
with:
|
|
165
|
+
name: rapidocr_ng-wheels-aarch64
|
|
166
|
+
path: wheelhouse/*.whl
|
|
167
|
+
if-no-files-found: error
|
|
168
|
+
|
|
169
|
+
dist:
|
|
170
|
+
name: SHA256SUMS
|
|
171
|
+
needs: [sdist, wheels-x86_64, wheels-aarch64, wheels-aarch64-qemu]
|
|
172
|
+
if: >-
|
|
173
|
+
always() &&
|
|
174
|
+
needs.sdist.result == 'success' &&
|
|
175
|
+
needs.wheels-x86_64.result == 'success' &&
|
|
176
|
+
(needs.wheels-aarch64.result == 'success' || needs.wheels-aarch64-qemu.result == 'success')
|
|
177
|
+
runs-on: ubuntu-latest
|
|
178
|
+
steps:
|
|
179
|
+
- uses: actions/download-artifact@v4
|
|
180
|
+
with:
|
|
181
|
+
pattern: rapidocr_ng-*
|
|
182
|
+
merge-multiple: true
|
|
183
|
+
path: dist
|
|
184
|
+
|
|
185
|
+
- name: Write SHA256SUMS
|
|
186
|
+
run: |
|
|
187
|
+
rm -f dist/SHA256SUMS
|
|
188
|
+
(cd dist && sha256sum ./*.whl ./*.tar.gz | tee SHA256SUMS)
|
|
189
|
+
|
|
190
|
+
- uses: actions/upload-artifact@v4
|
|
191
|
+
with:
|
|
192
|
+
name: rapidocr_ng-dist
|
|
193
|
+
path: |
|
|
194
|
+
dist/*.whl
|
|
195
|
+
dist/*.tar.gz
|
|
196
|
+
dist/SHA256SUMS
|
|
197
|
+
if-no-files-found: error
|
|
198
|
+
|
|
199
|
+
publish:
|
|
200
|
+
name: PyPI and GitHub Release
|
|
201
|
+
needs: dist
|
|
202
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v5')
|
|
203
|
+
runs-on: ubuntu-latest
|
|
204
|
+
environment: pypi
|
|
205
|
+
permissions:
|
|
206
|
+
id-token: write
|
|
207
|
+
contents: write
|
|
208
|
+
steps:
|
|
209
|
+
- uses: actions/download-artifact@v4
|
|
210
|
+
with:
|
|
211
|
+
name: rapidocr_ng-dist
|
|
212
|
+
path: dist
|
|
213
|
+
|
|
214
|
+
- name: Publish to PyPI
|
|
215
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
216
|
+
with:
|
|
217
|
+
packages-dir: dist
|
|
218
|
+
skip-existing: true
|
|
219
|
+
attestations: false
|
|
220
|
+
verbose: true
|
|
221
|
+
|
|
222
|
+
- name: GitHub Release
|
|
223
|
+
uses: softprops/action-gh-release@v2
|
|
224
|
+
with:
|
|
225
|
+
files: |
|
|
226
|
+
dist/*.whl
|
|
227
|
+
dist/*.tar.gz
|
|
228
|
+
dist/SHA256SUMS
|
|
229
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
name: vulkan lavapipe
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- V5_NG
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- V5_NG
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: vulkan-${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
lavapipe:
|
|
21
|
+
name: lavapipe
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
submodules: recursive
|
|
27
|
+
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.12"
|
|
31
|
+
|
|
32
|
+
- name: Install the software Vulkan stack
|
|
33
|
+
run: |
|
|
34
|
+
sudo apt-get update
|
|
35
|
+
sudo apt-get install -y --no-install-recommends \
|
|
36
|
+
mesa-vulkan-drivers vulkan-tools vulkan-validationlayers \
|
|
37
|
+
glslang-tools ninja-build cmake g++
|
|
38
|
+
|
|
39
|
+
- name: Cache tiny models
|
|
40
|
+
uses: actions/cache@v4
|
|
41
|
+
with:
|
|
42
|
+
path: ci-models
|
|
43
|
+
key: rapidocr-ci-models-tiny-v1
|
|
44
|
+
|
|
45
|
+
- name: Download tiny models when the cache is empty
|
|
46
|
+
run: python python/tests/fetch_ci_models.py
|
|
47
|
+
|
|
48
|
+
- name: Build with embedded Vulkan shaders
|
|
49
|
+
run: |
|
|
50
|
+
cmake -S . -B build-vk -G Ninja \
|
|
51
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
52
|
+
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
|
|
53
|
+
-DPPOCR_BUILD_STATIC=OFF \
|
|
54
|
+
-DPPOCR_BUILD_TESTS=ON \
|
|
55
|
+
-DPPOCR_BUILD_EXAMPLES=ON \
|
|
56
|
+
-DPPOCR_ENABLE_VULKAN=ON
|
|
57
|
+
cmake --build build-vk -j"$(nproc)"
|
|
58
|
+
|
|
59
|
+
- name: Confirm the library does not link libvulkan
|
|
60
|
+
run: |
|
|
61
|
+
if objdump -p build-vk/libppocr.so | grep -E 'NEEDED[[:space:]]+libvulkan'; then
|
|
62
|
+
echo "libppocr.so must dlopen libvulkan, not DT_NEEDED it" >&2
|
|
63
|
+
exit 1
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
- name: Install Python test dependencies
|
|
67
|
+
run: |
|
|
68
|
+
python -m pip install -r python/tests/ci-constraints.txt \
|
|
69
|
+
pytest PyYAML requests tqdm
|
|
70
|
+
|
|
71
|
+
- name: Lavapipe hello, kernels, and fallback
|
|
72
|
+
env:
|
|
73
|
+
VK_ICD_FILENAMES: /usr/share/vulkan/icd.d/lvp_icd.json
|
|
74
|
+
PPOCR_VULKAN_DEVICE_INDEX: "0"
|
|
75
|
+
PPOCR_VULKAN_VALIDATION: "1"
|
|
76
|
+
run: bash tests/run_vulkan_lavapipe.sh build-vk
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Local build products and generated analysis output
|
|
2
|
+
/build*/
|
|
3
|
+
/bench/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
/python/dist/
|
|
7
|
+
/python/*.egg-info/
|
|
8
|
+
/python/src/*.egg-info/
|
|
9
|
+
/python/.pytest_cache/
|
|
10
|
+
/ci-models/
|
|
11
|
+
/wheelhouse/
|
|
12
|
+
/dist/
|
|
13
|
+
/python/src/rapidocr/models/*
|
|
14
|
+
!/python/src/rapidocr/models/.gitkeep
|
|
15
|
+
/**/graphify-out/
|
|
16
|
+
/build-msvc-env.txt
|
|
17
|
+
|
|
18
|
+
# Nested vendor repository metadata; vendor source is committed as normal files.
|
|
19
|
+
/third_party/Vulkan-Headers/.git/
|
|
20
|
+
|
|
21
|
+
# Editor and OS files
|
|
22
|
+
.vs/
|
|
23
|
+
.idea/
|
|
24
|
+
*.user
|
|
25
|
+
*.suo
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(ppocr_cpp VERSION 5.0.0 LANGUAGES C CXX)
|
|
3
|
+
|
|
4
|
+
include(GNUInstallDirs)
|
|
5
|
+
include(CMakePackageConfigHelpers)
|
|
6
|
+
|
|
7
|
+
option(PPOCR_BUILD_SHARED "Build the shared library" ON)
|
|
8
|
+
option(PPOCR_BUILD_STATIC "Build the static library" ON)
|
|
9
|
+
option(PPOCR_BUILD_EXAMPLES "Build examples and smoke tools" ON)
|
|
10
|
+
option(PPOCR_BUILD_TESTS "Build the C API smoke test" ON)
|
|
11
|
+
# Shaders are compiled into the library. The loader is dlopen'd, so this does
|
|
12
|
+
# not add a libvulkan DT_NEEDED entry. Wheels pass OFF: manylinux images do
|
|
13
|
+
# not ship glslang, and the published CPU wheel must not change when the
|
|
14
|
+
# image happens to contain a shader compiler.
|
|
15
|
+
option(PPOCR_ENABLE_VULKAN "Embed Vulkan compute shaders when headers and glslangValidator are available" ON)
|
|
16
|
+
|
|
17
|
+
if(NOT PPOCR_BUILD_SHARED AND NOT PPOCR_BUILD_STATIC)
|
|
18
|
+
message(FATAL_ERROR "Enable PPOCR_BUILD_SHARED and/or PPOCR_BUILD_STATIC")
|
|
19
|
+
endif()
|
|
20
|
+
|
|
21
|
+
set(PPOCR_SOURCES
|
|
22
|
+
src/kernels.cpp
|
|
23
|
+
src/onnx_lite.cpp
|
|
24
|
+
src/ppocr.cpp
|
|
25
|
+
src/vulkan_backend.cpp
|
|
26
|
+
src/ppocr_c_api.cpp
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
add_library(ppocr_objects OBJECT ${PPOCR_SOURCES})
|
|
30
|
+
set_target_properties(ppocr_objects PROPERTIES
|
|
31
|
+
POSITION_INDEPENDENT_CODE ON
|
|
32
|
+
CXX_VISIBILITY_PRESET hidden
|
|
33
|
+
VISIBILITY_INLINES_HIDDEN ON)
|
|
34
|
+
target_compile_definitions(ppocr_objects PRIVATE PPOCR_BUILDING_SHARED)
|
|
35
|
+
target_include_directories(ppocr_objects PUBLIC
|
|
36
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
37
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
38
|
+
target_compile_features(ppocr_objects PUBLIC cxx_std_20)
|
|
39
|
+
|
|
40
|
+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Vulkan-Headers/include/vulkan/vulkan.h")
|
|
41
|
+
target_include_directories(ppocr_objects PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/Vulkan-Headers/include)
|
|
42
|
+
target_compile_definitions(ppocr_objects PRIVATE PPOCR_HAS_VULKAN_HEADERS=1)
|
|
43
|
+
endif()
|
|
44
|
+
# The vendored glslang.exe is a Windows compiler. On Linux/ARM use a host
|
|
45
|
+
# glslangValidator so the build does not try to execute a PE binary.
|
|
46
|
+
if(WIN32 AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glslang/bin/glslang.exe")
|
|
47
|
+
set(PPOCR_GLSLANG "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glslang/bin/glslang.exe")
|
|
48
|
+
else()
|
|
49
|
+
find_program(PPOCR_GLSLANG NAMES glslangValidator glslang)
|
|
50
|
+
endif()
|
|
51
|
+
if(PPOCR_ENABLE_VULKAN AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Vulkan-Headers/include/vulkan/vulkan.h" AND PPOCR_GLSLANG)
|
|
52
|
+
set(PPOCR_VULKAN_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
53
|
+
set(PPOCR_VULKAN_SPV "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_binary.spv")
|
|
54
|
+
set(PPOCR_VULKAN_SPV_HEADER "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_binary_spv.hpp")
|
|
55
|
+
set(PPOCR_VULKAN_TAIL_SPV "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_depthwise_tail.spv")
|
|
56
|
+
set(PPOCR_VULKAN_TAIL_SPV_HEADER "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_depthwise_tail_spv.hpp")
|
|
57
|
+
set(PPOCR_VULKAN_POINTWISE_TAIL_SPV "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_pointwise_tail.spv")
|
|
58
|
+
set(PPOCR_VULKAN_POINTWISE_TAIL_SPV_HEADER "${PPOCR_VULKAN_GENERATED_DIR}/vulkan_pointwise_tail_spv.hpp")
|
|
59
|
+
add_custom_command(
|
|
60
|
+
OUTPUT "${PPOCR_VULKAN_SPV}" "${PPOCR_VULKAN_SPV_HEADER}" "${PPOCR_VULKAN_TAIL_SPV}" "${PPOCR_VULKAN_TAIL_SPV_HEADER}" "${PPOCR_VULKAN_POINTWISE_TAIL_SPV}" "${PPOCR_VULKAN_POINTWISE_TAIL_SPV_HEADER}"
|
|
61
|
+
COMMAND ${CMAKE_COMMAND} -E make_directory "${PPOCR_VULKAN_GENERATED_DIR}"
|
|
62
|
+
COMMAND "${PPOCR_GLSLANG}" -V -S comp -o "${PPOCR_VULKAN_SPV}" "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_binary.comp"
|
|
63
|
+
COMMAND "${PPOCR_GLSLANG}" -V -S comp -o "${PPOCR_VULKAN_TAIL_SPV}" "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_depthwise_tail.comp"
|
|
64
|
+
COMMAND "${PPOCR_GLSLANG}" -V -S comp -o "${PPOCR_VULKAN_POINTWISE_TAIL_SPV}" "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_pointwise_tail.comp"
|
|
65
|
+
COMMAND ${CMAKE_COMMAND} -DINPUT=${PPOCR_VULKAN_SPV} -DOUTPUT=${PPOCR_VULKAN_SPV_HEADER} -DNAME=kVulkanBinarySpv -P "${CMAKE_CURRENT_SOURCE_DIR}/src/embed_spirv.cmake"
|
|
66
|
+
COMMAND ${CMAKE_COMMAND} -DINPUT=${PPOCR_VULKAN_TAIL_SPV} -DOUTPUT=${PPOCR_VULKAN_TAIL_SPV_HEADER} -DNAME=kVulkanDepthwiseTailSpv -P "${CMAKE_CURRENT_SOURCE_DIR}/src/embed_spirv.cmake"
|
|
67
|
+
COMMAND ${CMAKE_COMMAND} -DINPUT=${PPOCR_VULKAN_POINTWISE_TAIL_SPV} -DOUTPUT=${PPOCR_VULKAN_POINTWISE_TAIL_SPV_HEADER} -DNAME=kVulkanPointwiseTailSpv -P "${CMAKE_CURRENT_SOURCE_DIR}/src/embed_spirv.cmake"
|
|
68
|
+
COMMAND ${CMAKE_COMMAND} -E touch "${PPOCR_VULKAN_SPV_HEADER}"
|
|
69
|
+
COMMAND ${CMAKE_COMMAND} -E touch "${PPOCR_VULKAN_TAIL_SPV_HEADER}"
|
|
70
|
+
COMMAND ${CMAKE_COMMAND} -E touch "${PPOCR_VULKAN_POINTWISE_TAIL_SPV_HEADER}"
|
|
71
|
+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_binary.comp" "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_depthwise_tail.comp" "${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_pointwise_tail.comp" "${CMAKE_CURRENT_SOURCE_DIR}/src/embed_spirv.cmake" "${PPOCR_GLSLANG}"
|
|
72
|
+
VERBATIM)
|
|
73
|
+
add_custom_target(ppocr_vulkan_shader DEPENDS "${PPOCR_VULKAN_SPV_HEADER}" "${PPOCR_VULKAN_TAIL_SPV_HEADER}" "${PPOCR_VULKAN_POINTWISE_TAIL_SPV_HEADER}")
|
|
74
|
+
add_dependencies(ppocr_objects ppocr_vulkan_shader)
|
|
75
|
+
target_include_directories(ppocr_objects PRIVATE "${PPOCR_VULKAN_GENERATED_DIR}")
|
|
76
|
+
target_compile_definitions(ppocr_objects PRIVATE PPOCR_HAS_VULKAN_KERNELS=1)
|
|
77
|
+
elseif(NOT PPOCR_ENABLE_VULKAN)
|
|
78
|
+
message(STATUS "Vulkan compute shaders disabled by PPOCR_ENABLE_VULKAN=OFF")
|
|
79
|
+
else()
|
|
80
|
+
message(STATUS "Vulkan compute shaders disabled: need Vulkan-Headers and glslangValidator")
|
|
81
|
+
endif()
|
|
82
|
+
|
|
83
|
+
if(MSVC)
|
|
84
|
+
target_compile_options(ppocr_objects PRIVATE /W4 /permissive- /O2 /fp:fast)
|
|
85
|
+
else()
|
|
86
|
+
target_compile_options(ppocr_objects PRIVATE -Wall -Wextra -Wpedantic -O3 -ffast-math -funroll-loops)
|
|
87
|
+
endif()
|
|
88
|
+
|
|
89
|
+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR};${CMAKE_GENERATOR_PLATFORM}" PPOCR_CPU)
|
|
90
|
+
if(NOT MSVC AND PPOCR_CPU MATCHES "x86_64|amd64|x64|i[3-6]86")
|
|
91
|
+
# Baseline translation units stay SSE2. Auto-vectorization must not emit
|
|
92
|
+
# AVX or AVX-512, or an AVX2-only machine will SIGILL inside the fallback.
|
|
93
|
+
set_source_files_properties(
|
|
94
|
+
src/kernels.cpp src/onnx_lite.cpp src/ppocr.cpp src/vulkan_backend.cpp src/ppocr_c_api.cpp
|
|
95
|
+
PROPERTIES COMPILE_OPTIONS "-mno-avx;-mno-avx2;-mno-avx512f")
|
|
96
|
+
endif()
|
|
97
|
+
|
|
98
|
+
# AVX2 is isolated in its own object file. kernels.cpp remains baseline x86,
|
|
99
|
+
# so CPUs without AVX/AVX2 can safely take its scalar fallback at runtime.
|
|
100
|
+
if(PPOCR_CPU MATCHES "x86_64|amd64|x64|i[3-6]86")
|
|
101
|
+
target_sources(ppocr_objects PRIVATE src/kernels_avx2.cpp)
|
|
102
|
+
target_compile_definitions(ppocr_objects PRIVATE PPOCR_HAS_AVX2_KERNELS=1)
|
|
103
|
+
if(MSVC)
|
|
104
|
+
set_source_files_properties(src/kernels_avx2.cpp PROPERTIES COMPILE_OPTIONS "/arch:AVX2;/fp:fast")
|
|
105
|
+
else()
|
|
106
|
+
# -mno-avx512* is last-wins together with -mavx2 and forbids the compiler
|
|
107
|
+
# from rewriting this file with EVEX/zmm encodings.
|
|
108
|
+
set_source_files_properties(src/kernels_avx2.cpp PROPERTIES COMPILE_OPTIONS
|
|
109
|
+
"-mavx2;-mfma;-mno-avx512f;-mno-avx512bw;-mno-avx512vl;-mno-avx512dq")
|
|
110
|
+
endif()
|
|
111
|
+
target_sources(ppocr_objects PRIVATE src/kernels_avx512.cpp)
|
|
112
|
+
target_compile_definitions(ppocr_objects PRIVATE PPOCR_HAS_AVX512_KERNELS=1)
|
|
113
|
+
if(MSVC)
|
|
114
|
+
set_source_files_properties(src/kernels_avx512.cpp PROPERTIES COMPILE_OPTIONS "/arch:AVX512;/fp:fast")
|
|
115
|
+
else()
|
|
116
|
+
# This TU uses AVX-512F/DQ/BW/VL plus BMI tzcnt. None of those encodings
|
|
117
|
+
# are enabled in kernels.cpp or kernels_avx2.cpp. HasAvx512() requires
|
|
118
|
+
# the same feature bits before the TU is entered.
|
|
119
|
+
set_source_files_properties(src/kernels_avx512.cpp PROPERTIES COMPILE_OPTIONS
|
|
120
|
+
"-mavx512f;-mavx512dq;-mavx512bw;-mavx512vl;-mbmi;-mbmi2;-mfma")
|
|
121
|
+
endif()
|
|
122
|
+
endif()
|
|
123
|
+
|
|
124
|
+
set(PPOCR_INSTALL_TARGETS "")
|
|
125
|
+
|
|
126
|
+
if(PPOCR_BUILD_STATIC)
|
|
127
|
+
add_library(ppocr STATIC $<TARGET_OBJECTS:ppocr_objects>)
|
|
128
|
+
target_include_directories(ppocr PUBLIC
|
|
129
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
130
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
131
|
+
target_compile_features(ppocr PUBLIC cxx_std_20)
|
|
132
|
+
if(UNIX AND NOT APPLE)
|
|
133
|
+
target_link_libraries(ppocr PUBLIC ${CMAKE_DL_LIBS})
|
|
134
|
+
endif()
|
|
135
|
+
set_target_properties(ppocr PROPERTIES OUTPUT_NAME ppocr EXPORT_NAME static)
|
|
136
|
+
if(WIN32)
|
|
137
|
+
set_target_properties(ppocr PROPERTIES OUTPUT_NAME ppocr_static)
|
|
138
|
+
endif()
|
|
139
|
+
add_library(ppocr::static ALIAS ppocr)
|
|
140
|
+
list(APPEND PPOCR_INSTALL_TARGETS ppocr)
|
|
141
|
+
endif()
|
|
142
|
+
|
|
143
|
+
if(PPOCR_BUILD_SHARED)
|
|
144
|
+
add_library(ppocr_shared SHARED $<TARGET_OBJECTS:ppocr_objects>)
|
|
145
|
+
target_include_directories(ppocr_shared PUBLIC
|
|
146
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
147
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
148
|
+
target_compile_features(ppocr_shared PUBLIC cxx_std_20)
|
|
149
|
+
target_compile_definitions(ppocr_shared PUBLIC PPOCR_SHARED)
|
|
150
|
+
if(UNIX AND NOT APPLE)
|
|
151
|
+
target_link_libraries(ppocr_shared PRIVATE ${CMAKE_DL_LIBS})
|
|
152
|
+
endif()
|
|
153
|
+
set_target_properties(ppocr_shared PROPERTIES
|
|
154
|
+
OUTPUT_NAME ppocr
|
|
155
|
+
EXPORT_NAME ppocr
|
|
156
|
+
VERSION ${PROJECT_VERSION}
|
|
157
|
+
SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
158
|
+
add_library(ppocr::ppocr ALIAS ppocr_shared)
|
|
159
|
+
list(APPEND PPOCR_INSTALL_TARGETS ppocr_shared)
|
|
160
|
+
endif()
|
|
161
|
+
|
|
162
|
+
function(ppocr_link_runtime target)
|
|
163
|
+
if(PPOCR_BUILD_STATIC)
|
|
164
|
+
target_link_libraries(${target} PRIVATE ppocr)
|
|
165
|
+
else()
|
|
166
|
+
target_link_libraries(${target} PRIVATE ppocr_shared)
|
|
167
|
+
endif()
|
|
168
|
+
endfunction()
|
|
169
|
+
|
|
170
|
+
# Smoke tools call detail:: symbols. Those symbols are hidden in the shared
|
|
171
|
+
# library, so the tools link the object files instead.
|
|
172
|
+
function(ppocr_link_objects target)
|
|
173
|
+
target_link_libraries(${target} PRIVATE $<TARGET_OBJECTS:ppocr_objects>)
|
|
174
|
+
target_include_directories(${target} PRIVATE
|
|
175
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
176
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src")
|
|
177
|
+
target_compile_features(${target} PRIVATE cxx_std_20)
|
|
178
|
+
if(UNIX AND NOT APPLE)
|
|
179
|
+
target_link_libraries(${target} PRIVATE ${CMAKE_DL_LIBS})
|
|
180
|
+
endif()
|
|
181
|
+
endfunction()
|
|
182
|
+
|
|
183
|
+
if(PPOCR_BUILD_EXAMPLES)
|
|
184
|
+
add_executable(ppocr_demo examples/ppocr_demo.cpp)
|
|
185
|
+
ppocr_link_runtime(ppocr_demo)
|
|
186
|
+
|
|
187
|
+
add_executable(ppocr_cpp_api_demo examples/cpp_api_demo.cpp)
|
|
188
|
+
target_link_libraries(ppocr_cpp_api_demo PRIVATE $<IF:$<BOOL:${PPOCR_BUILD_SHARED}>,ppocr_shared,ppocr>)
|
|
189
|
+
if(PPOCR_BUILD_SHARED)
|
|
190
|
+
set_target_properties(ppocr_cpp_api_demo PROPERTIES BUILD_RPATH "$<TARGET_FILE_DIR:ppocr_shared>")
|
|
191
|
+
endif()
|
|
192
|
+
|
|
193
|
+
add_executable(ppocr_c_api_demo examples/c_api_demo.c)
|
|
194
|
+
target_link_libraries(ppocr_c_api_demo PRIVATE $<IF:$<BOOL:${PPOCR_BUILD_SHARED}>,ppocr_shared,ppocr>)
|
|
195
|
+
if(PPOCR_BUILD_SHARED)
|
|
196
|
+
set_target_properties(ppocr_c_api_demo PROPERTIES BUILD_RPATH "$<TARGET_FILE_DIR:ppocr_shared>")
|
|
197
|
+
endif()
|
|
198
|
+
|
|
199
|
+
add_executable(ppocr_isa_bench examples/ppocr_isa_bench.cpp)
|
|
200
|
+
ppocr_link_objects(ppocr_isa_bench)
|
|
201
|
+
|
|
202
|
+
add_executable(ppocr_bench examples/ppocr_bench.cpp)
|
|
203
|
+
ppocr_link_runtime(ppocr_bench)
|
|
204
|
+
|
|
205
|
+
add_executable(ppocr_mem_soak examples/ppocr_mem_soak.cpp)
|
|
206
|
+
ppocr_link_runtime(ppocr_mem_soak)
|
|
207
|
+
if(WIN32)
|
|
208
|
+
target_link_libraries(ppocr_mem_soak PRIVATE psapi)
|
|
209
|
+
endif()
|
|
210
|
+
|
|
211
|
+
add_executable(ppocr_vulkan_smoke examples/ppocr_vulkan_smoke.cpp)
|
|
212
|
+
ppocr_link_objects(ppocr_vulkan_smoke)
|
|
213
|
+
|
|
214
|
+
add_executable(ppocr_batch_smoke examples/ppocr_batch_smoke.cpp)
|
|
215
|
+
ppocr_link_runtime(ppocr_batch_smoke)
|
|
216
|
+
|
|
217
|
+
add_executable(ppocr_kernel_smoke examples/ppocr_kernel_smoke.cpp)
|
|
218
|
+
ppocr_link_objects(ppocr_kernel_smoke)
|
|
219
|
+
|
|
220
|
+
add_executable(ppocr_determinism examples/ppocr_determinism.cpp)
|
|
221
|
+
ppocr_link_objects(ppocr_determinism)
|
|
222
|
+
|
|
223
|
+
add_executable(ppocr_gpu_graph_smoke examples/ppocr_gpu_graph_smoke.cpp)
|
|
224
|
+
ppocr_link_objects(ppocr_gpu_graph_smoke)
|
|
225
|
+
|
|
226
|
+
add_executable(ppocr_gpu_frontend_smoke examples/ppocr_gpu_frontend_smoke.cpp)
|
|
227
|
+
ppocr_link_objects(ppocr_gpu_frontend_smoke)
|
|
228
|
+
|
|
229
|
+
add_executable(ppocr_gpu_pipeline_smoke examples/ppocr_gpu_pipeline_smoke.cpp)
|
|
230
|
+
ppocr_link_objects(ppocr_gpu_pipeline_smoke)
|
|
231
|
+
|
|
232
|
+
add_executable(ppocr_gpu_ocr_smoke examples/ppocr_gpu_ocr_smoke.cpp)
|
|
233
|
+
ppocr_link_runtime(ppocr_gpu_ocr_smoke)
|
|
234
|
+
|
|
235
|
+
add_executable(ppocr_vulkan_robust examples/ppocr_vulkan_robust.cpp)
|
|
236
|
+
ppocr_link_runtime(ppocr_vulkan_robust)
|
|
237
|
+
|
|
238
|
+
add_executable(ppocr_gpu_graph_mem_soak examples/ppocr_gpu_graph_mem_soak.cpp)
|
|
239
|
+
ppocr_link_objects(ppocr_gpu_graph_mem_soak)
|
|
240
|
+
endif()
|
|
241
|
+
|
|
242
|
+
if(PPOCR_BUILD_TESTS)
|
|
243
|
+
add_executable(ppocr_c_api_smoke tests/c_api_smoke.c)
|
|
244
|
+
target_link_libraries(ppocr_c_api_smoke PRIVATE $<IF:$<BOOL:${PPOCR_BUILD_SHARED}>,ppocr_shared,ppocr>)
|
|
245
|
+
if(PPOCR_BUILD_SHARED)
|
|
246
|
+
set_target_properties(ppocr_c_api_smoke PROPERTIES BUILD_RPATH "$<TARGET_FILE_DIR:ppocr_shared>")
|
|
247
|
+
endif()
|
|
248
|
+
enable_testing()
|
|
249
|
+
add_test(NAME c_api_smoke COMMAND ppocr_c_api_smoke)
|
|
250
|
+
if(NOT MSVC AND PPOCR_CPU MATCHES "x86_64|amd64|x64|i[3-6]86")
|
|
251
|
+
add_test(NAME isa_encoding
|
|
252
|
+
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_isa_encoding.sh
|
|
253
|
+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ppocr_objects.dir/src/kernels.cpp.o
|
|
254
|
+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ppocr_objects.dir/src/kernels_avx2.cpp.o
|
|
255
|
+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ppocr_objects.dir/src/kernels_avx512.cpp.o)
|
|
256
|
+
endif()
|
|
257
|
+
endif()
|
|
258
|
+
|
|
259
|
+
if(NOT SKBUILD)
|
|
260
|
+
install(TARGETS ${PPOCR_INSTALL_TARGETS}
|
|
261
|
+
EXPORT ppocrTargets
|
|
262
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
263
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
264
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
265
|
+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
266
|
+
install(DIRECTORY include/ppocr DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
267
|
+
install(EXPORT ppocrTargets
|
|
268
|
+
NAMESPACE ppocr::
|
|
269
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ppocr)
|
|
270
|
+
configure_package_config_file(
|
|
271
|
+
cmake/ppocrConfig.cmake.in
|
|
272
|
+
${CMAKE_CURRENT_BINARY_DIR}/ppocrConfig.cmake
|
|
273
|
+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ppocr)
|
|
274
|
+
write_basic_package_version_file(
|
|
275
|
+
${CMAKE_CURRENT_BINARY_DIR}/ppocrConfigVersion.cmake
|
|
276
|
+
COMPATIBILITY SameMajorVersion)
|
|
277
|
+
install(FILES
|
|
278
|
+
${CMAKE_CURRENT_BINARY_DIR}/ppocrConfig.cmake
|
|
279
|
+
${CMAKE_CURRENT_BINARY_DIR}/ppocrConfigVersion.cmake
|
|
280
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ppocr)
|
|
281
|
+
else()
|
|
282
|
+
# scikit-build-core stages the shared library next to the Python package.
|
|
283
|
+
if(NOT PPOCR_BUILD_SHARED)
|
|
284
|
+
message(FATAL_ERROR "The Python wheel needs PPOCR_BUILD_SHARED=ON")
|
|
285
|
+
endif()
|
|
286
|
+
install(TARGETS ppocr_shared
|
|
287
|
+
LIBRARY DESTINATION "${SKBUILD_PLATLIB_DIR}/rapidocr"
|
|
288
|
+
RUNTIME DESTINATION "${SKBUILD_PLATLIB_DIR}/rapidocr"
|
|
289
|
+
ARCHIVE DESTINATION "${SKBUILD_PLATLIB_DIR}/rapidocr")
|
|
290
|
+
endif()
|