Implicit conversion into nb::ndarray in C++ by custom type_cast #240
Unanswered
Char-Aznable
asked this question in
Q&A
Replies: 2 comments
-
BTW, I have tried not using type_cast at all but merge those conversion code into the |
Beta Was this translation helpful? Give feedback.
0 replies
-
It turns out type_caster's SFINAE is not working. The type cast works if I do the following without the SFINAE: template <class ... T>
struct type_caster<MDArray<T...>> {
// the static_assert never fires, which means the OP's code should have worked
static_assert(isMDArray<MDArray<T...>>>, "should not fire");
}; Now I'm not sure what the expected signature of the SFINAE as in the Eigen array case... |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, thanks for this great library. I'm new to this so any suggestion is welcome. I have a custom multi-dimensional array C++ class that I need to convert into pytorch tensor upon some function call. I have written the
nb::detail::type_cast
specialization for it by following the Eigen array conversion:nanobind/include/nanobind/eigen/dense.h
Line 124 in 827c083
nb::class_
method that returns directly the custom multi-dimensional array C++ class and expect I that would get the desired pytorch tensor but instead I got the error when calling the function on python:TypeError: Unable to convert function return value to a Python type!
My question is: should I expect this implicit conversion to work? What should I look into about the conversion error?
The structure of the code I mentioned looks something like:
Beta Was this translation helpful? Give feedback.
All reactions