Skip to content

Commit 8048540

Browse files
author
ONNX GenAI Assistant
committed
fix: Fix memory leaks in NamedTensors and other bindings
- Use RAII wrapper for OgaStringArray instead of new/delete - Fix __contains__ to properly clean up temporary tensor - Revert incorrect inst_alloc usage for __getitem__
1 parent 2ba19e1 commit 8048540

File tree

212 files changed

+58992
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+58992
-5
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Other
2+
description: Ask a question or request a new feature
3+
title: "[OTHER]: "
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## Important information
9+
For all types of questions, feature requests, and other issues that aren't nanobind bugs, please start a post on the separate "Discussions" tab and *not* under "Issues".
10+
11+
If have found a nanobind bug, then please open a ticket with a reproducer using the separate "Bug Report" template.
12+
13+
- type: textarea
14+
id: description
15+
attributes:
16+
label: Please don't use.
17+
placeholder: >-
18+
For all types of questions, feature requests, and other issues that aren't nanobind bugs, please start a post on the separate "Discussions" tab and *not* under "Issues".
19+
20+
If have found a nanobind bug, then please open a ticket with a reproducer using the separate "Bug Report" template.
21+
22+
validations:
23+
required: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Bug report
2+
description: File an issue about a critical issue in nanobind
3+
title: "[BUG]: "
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
## Important information
9+
The author's time for processing GitHub issues is unfortunately very limited. Because of this, _nanobind_ cannot accept feature requests. Furthermore, questions should not be submitted here, please use the separate "Discussions" tab. I will unfortunately need to close feature requests or questions maquerading as bug reports.
10+
11+
- type: textarea
12+
id: description
13+
attributes:
14+
label: Problem description
15+
placeholder: >-
16+
Provide a short description, state the expected behavior and what
17+
actually happens. Include relevant information like what version of
18+
Python and nanobind you are using, what system you are on, and any
19+
useful commands / output.
20+
validations:
21+
required: true
22+
23+
- type: textarea
24+
id: code
25+
attributes:
26+
label: Reproducible example code
27+
placeholder: >-
28+
The code should be minimal, have no external dependencies, and isolate the
29+
function(s) that cause breakage. Please submit matched and complete C++ and
30+
Python snippets that can be easily compiled and run to diagnose the
31+
issue. If possible, make a PR with a failing test to provide a
32+
starting point for me to work on.
33+
render: text
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
- stable
10+
- v*
11+
12+
concurrency:
13+
group: test-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
# This is the "main" test suite, which tests a large number of different
18+
# versions of default compilers and Python versions in GitHub Actions.
19+
standard:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: ['ubuntu-latest', 'windows-2022', 'macos-13']
24+
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14.0-rc.2', 'pypy3.9-v7.3.16', 'pypy3.10-v7.3.17']
25+
26+
name: "Python ${{ matrix.python }} / ${{ matrix.os }}"
27+
runs-on: ${{ matrix.os }}
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: true
33+
34+
- name: Setup Python ${{ matrix.python }}
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ matrix.python }}
38+
cache: 'pip'
39+
40+
- name: Install the latest CMake
41+
uses: lukka/get-cmake@latest
42+
43+
- name: Install Eigen
44+
if: matrix.os == 'ubuntu-latest'
45+
run: sudo apt-get -y install libeigen3-dev
46+
47+
- name: Install PyTest
48+
run: |
49+
python -m pip install pytest pytest-github-actions-annotate-failures typing_extensions
50+
51+
- name: Install NumPy
52+
if: ${{ !startsWith(matrix.python, 'pypy') && !contains(matrix.python, 'alpha') }}
53+
run: |
54+
python -m pip install numpy scipy
55+
56+
- name: Configure
57+
run: >
58+
cmake -S . -B build -DNB_TEST_STABLE_ABI=ON -DNB_TEST_SHARED_BUILD="$(python -c 'import sys; print(int(sys.version_info.minor>=11))')"
59+
60+
- name: Build C++
61+
run: cmake --build build -j 2
62+
63+
- name: Check ABI tag
64+
if: ${{ !startsWith(matrix.os, 'windows') }}
65+
run: >
66+
cd build/tests;
67+
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
68+
69+
- name: Check ABI tag
70+
if: ${{ startsWith(matrix.os, 'windows') }}
71+
run: >
72+
cd build/tests/Debug;
73+
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
74+
75+
- name: Run tests
76+
run: >
77+
cd build;
78+
python -m pytest
79+
80+
nvcc-ubuntu:
81+
runs-on: ubuntu-latest
82+
container: nvidia/cuda:12.5.1-devel-ubuntu24.04
83+
name: "Python 3 / NVCC (CUDA 12.6.1) / ubuntu-latest"
84+
85+
steps:
86+
- name: Install dependencies
87+
run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake git python3-dev python3-pytest python3-pip libeigen3-dev python3-typing-extensions python3-numpy
88+
89+
- uses: actions/checkout@v4
90+
with:
91+
submodules: true
92+
93+
- name: Configure
94+
run: >
95+
cmake -S . -B build -DNB_TEST_CUDA=ON
96+
97+
- name: Build C++
98+
run: cmake --build build -j 2
99+
100+
- name: Check ABI tag
101+
run: >
102+
cd build/tests;
103+
python3 -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
104+
105+
- name: Run tests
106+
run: >
107+
cd build;
108+
python3 -m pytest
109+
110+
old-compilers:
111+
if: false # Disable for now, the CI is glitchy
112+
strategy:
113+
fail-fast: false
114+
matrix:
115+
include:
116+
- cc: gcc-8
117+
cxx: g++-8
118+
apt: gcc-8 g++-8
119+
- cc: gcc-9
120+
cxx: g++-9
121+
apt: gcc-9
122+
- cc: clang-8
123+
cxx: clang++-8
124+
apt: clang-8
125+
- cc: clang-9
126+
cxx: clang++-9
127+
apt: clang-9
128+
- cc: clang-10
129+
cxx: clang++-10
130+
apt: clang-10
131+
132+
runs-on: ubuntu-latest
133+
container: ubuntu:20.04
134+
name: "${{matrix.cc}} on Ubuntu 20.04"
135+
env:
136+
CC: ${{matrix.cc}}
137+
CXX: ${{matrix.cxx}}
138+
DEBIAN_FRONTEND: noninteractive
139+
140+
steps:
141+
- name: Install dependencies
142+
run: |
143+
apt-get update
144+
apt-get install -y python3-numpy python3-pip python3-pytest libeigen3-dev cmake git ${{matrix.apt}}
145+
python3 -m pip install typing_extensions
146+
147+
- uses: actions/checkout@v4
148+
with:
149+
submodules: true
150+
151+
- name: Configure
152+
run: cmake -S . -B build
153+
154+
- name: Build C++
155+
run: cmake --build build -j 2
156+
157+
- name: Check ABI tag
158+
run: >
159+
cd build/tests;
160+
python3 -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
161+
162+
- name: Run tests
163+
run: >
164+
cd build;
165+
python3 -m pytest
166+
167+
free-threaded:
168+
name: "Python 3.14-dev / ubuntu.latest [free-threaded]"
169+
runs-on: ubuntu-latest
170+
171+
steps:
172+
- uses: actions/checkout@v4
173+
with:
174+
submodules: true
175+
176+
- uses: deadsnakes/[email protected]
177+
with:
178+
python-version: 3.14-dev
179+
nogil: true
180+
181+
- name: Install the latest CMake
182+
uses: lukka/get-cmake@latest
183+
184+
- name: Install PyTest
185+
run: |
186+
python -m pip install pytest pytest-github-actions-annotate-failures
187+
188+
- name: Configure
189+
run: >
190+
cmake -S . -B build -DNB_TEST_FREE_THREADED=ON
191+
192+
- name: Build C++
193+
run: >
194+
cmake --build build -j 2
195+
196+
- name: Check ABI tag
197+
run: >
198+
cd build/tests;
199+
python -c 'import test_functions_ext as t; print(f"ABI tag is \"{ t.abi_tag() }\"")'
200+
201+
- name: Run tests
202+
run: >
203+
cd build;
204+
python -m pytest
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Tests
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
nvcc-windows:
8+
runs-on: windows-latest
9+
name: "Python 3.12.7 / NVCC (CUDA 12.5.0) / windows-latest"
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
submodules: true
15+
16+
- uses: Jimver/[email protected]
17+
id: cuda-toolkit
18+
with:
19+
cuda: '12.5.0'
20+
21+
- name: Setup Python 3.12.5
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.12.5
25+
cache: 'pip'
26+
27+
- name: Install PyTest
28+
run: |
29+
python -m pip install pytest pytest-github-actions-annotate-failures typing_extensions
30+
31+
- name: Install NumPy
32+
run: |
33+
python -m pip install numpy scipy
34+
35+
- name: Configure
36+
run: >
37+
cmake -S . -B build -DNB_TEST_CUDA=ON
38+
39+
- name: Build C++
40+
run: cmake --build build -j 2 --config Release
41+
42+
- name: Run tests
43+
run: >
44+
cd build;
45+
python3 -m pytest

nanobind-2.9.2/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
libnanobind-static.a
2+
libnanobind-static-abi3.a
3+
libnanobind-static-ft.a
4+
libnanobind.so
5+
libnanobind-abi3.so
6+
libnanobind-ft.so
7+
libnanobind.dylib
8+
libnanobind-abi3.dylib
9+
libnanobind-ft.dylib
10+
nanobind.dll
11+
nanobind-abi3.dll
12+
nanobind-ft.dll
13+
14+
libinter_module.dylib
15+
libinter_module.so
16+
inter_module.dll
17+
18+
/.ninja_deps
19+
/.ninja_log
20+
/.cache
21+
/build.ninja
22+
/build
23+
/src/nanobind/cmake
24+
/src/nanobind/include
25+
/src/nanobind/ext
26+
/src/nanobind/src
27+
/dist
28+
/bench
29+
compile_commands.json
30+
31+
CMakeFiles
32+
CMakeCache.txt
33+
cmake_install.cmake
34+
nanobind-config-version.cmake
35+
\.DS_Store
36+
\.cmake
37+
__pycache__
38+
nanobind.egg-info
39+
test_*_ext*.so
40+
test_*_ext*.pyd
41+
*.pyi
42+
py\.typed
43+
.mypy_cache

nanobind-2.9.2/.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ext/robin_map"]
2+
path = ext/robin_map
3+
url = https://github.com/Tessil/robin-map

nanobind-2.9.2/.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
apt_packages:
6+
- librsvg2-bin
7+
tools:
8+
python: "3.11"
9+
10+
sphinx:
11+
configuration: docs/conf.py
12+
13+
python:
14+
install:
15+
- requirements: docs/requirements.txt
16+
17+
formats:
18+
- pdf

0 commit comments

Comments
 (0)