Skip to content

Commit 050d0c3

Browse files
committed
fix: preserve native module compatibility
1 parent 630ecce commit 050d0c3

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,31 @@ jobs:
5252
PY
5353
- name: Build native backend
5454
run: python -m fastvisionops.build
55+
- name: Verify portable native build
56+
run: |
57+
python -m fastvisionops.build \
58+
--no-openmp \
59+
--output "${RUNNER_TEMP}/libfastvisionops-portable.so"
60+
python - <<'PY'
61+
import os
62+
import numpy as np
63+
64+
from fastvisionops import NativeBackend
65+
66+
backend = NativeBackend(
67+
os.path.join(
68+
os.environ["RUNNER_TEMP"],
69+
"libfastvisionops-portable.so",
70+
)
71+
)
72+
np.testing.assert_array_equal(
73+
backend.nms(
74+
[[0, 0, 10, 10], [1, 1, 9, 9], [20, 20, 30, 30]],
75+
[0.9, 0.8, 0.7],
76+
),
77+
[0, 2],
78+
)
79+
PY
5580
- name: Run test suite
5681
run: python -m unittest discover -s tests -v
5782
- name: Smoke-test benchmark runners

fastvisionops/native/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
CBackend,
55
NativeBackend,
66
batch_multiclass_nms,
7+
hwc_to_chw_normalize,
8+
hwc_to_chw_normalize_batched,
79
load_backend,
810
multiclass_nms,
911
nms,
1012
)
13+
from .build import DEFAULT_OUTPUT
1114

1215
__all__ = [
1316
"CBackend",
17+
"DEFAULT_OUTPUT",
1418
"NativeBackend",
1519
"batch_multiclass_nms",
20+
"hwc_to_chw_normalize",
21+
"hwc_to_chw_normalize_batched",
1622
"load_backend",
1723
"multiclass_nms",
1824
"nms",

tests/test_package_layout.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@
66
from fastvisionops.bbox import nms as bbox_compat_nms
77
from fastvisionops.build import SOURCE, build_native_backend
88
from fastvisionops.mask import mask_nms as mask_compat_nms
9-
from fastvisionops.native import NativeBackend
10-
from fastvisionops.native.backend import NativeBackend as BackendImplementation
9+
from fastvisionops.native import (
10+
DEFAULT_OUTPUT,
11+
NativeBackend,
12+
hwc_to_chw_normalize as native_hwc_to_chw_normalize,
13+
hwc_to_chw_normalize_batched as native_hwc_to_chw_normalize_batched,
14+
)
15+
from fastvisionops.native.backend import (
16+
NativeBackend as BackendImplementation,
17+
hwc_to_chw_normalize as native_hwc_to_chw_normalize_implementation,
18+
hwc_to_chw_normalize_batched as native_batched_implementation,
19+
)
1120
from fastvisionops.native.build import (
21+
DEFAULT_OUTPUT as native_default_output,
1222
build_native_backend as native_build_native_backend,
1323
)
1424
from fastvisionops.postprocess import mask_nms as postprocess_mask_nms
@@ -47,6 +57,15 @@ def test_mask_import_paths_share_one_implementation(self):
4757
def test_preprocess_and_native_packages_expose_implementations(self):
4858
self.assertIs(hwc_to_chw_normalize, numpy_hwc_to_chw_normalize)
4959
self.assertIs(NativeBackend, BackendImplementation)
60+
self.assertIs(
61+
native_hwc_to_chw_normalize,
62+
native_hwc_to_chw_normalize_implementation,
63+
)
64+
self.assertIs(
65+
native_hwc_to_chw_normalize_batched,
66+
native_batched_implementation,
67+
)
68+
self.assertIs(DEFAULT_OUTPUT, native_default_output)
5069
self.assertIs(build_native_backend, native_build_native_backend)
5170

5271
def test_native_source_is_colocated_with_backend(self):

0 commit comments

Comments
 (0)