Higher-order functions hang #849
Unanswered
MarcelFerrari
asked this question in
Q&A
Replies: 1 comment
-
Not sure. It could be a GIL issue. Did you try to break in a debugger to see where the code is spending its time? In general, this issue has too many moving parts to help debug at the nanobind level. You will have to reduce it more if you'd like to open an issue ticket. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I am encountering a strange behaviour when calling a Nanobind function that accepts a stateful function argument from python.
I have the following function that is a member of an iterative linear system solver class. The solver accepts a MatrixReplacement object which wraps a std::function defining the matrix vector operation implicitly.
where:
This allows me to do something like this from Python:
This works absolutely great in a matrix-free context and has good performance.
The same Nanobind module also exposes a SparseMatrix object that I can assemble explicitly.
However, if I define a closure that captures in any way one of these SparseMatrix objects, then the C++ bindings hang and start consuming a large amount of memory. No explicit errors are thrown.
This only happens for objects of type SparseMatrix. Everything else is fine.
I feel like I am doing something fundamentally wrong, but I cannot seem to figure out what exactly.
Any inputs are much appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions