Skip to content

Any better way to deal with std::vector<Eigen> in nanobind/pybind? #426

Closed Answered by Kin-Zhang
Kin-Zhang asked this question in Q&A
Discussion options

You must be logged in to vote

Since inside cpp code, there are lots of func based on std::vector operators.

But I looked again this problem again recently and found a way to do similarly according to nanobind document Eigen convenience type aliases. It did speed up the run, from 0.1s to 0.01s around.

NB_MODULE(linefit, m) {
    nb::class_<GroundSegmentation>(m, "ground_seg")
        .def(nb::init<>(), "linefit ground segmentation constructor, param: ")
        .def(nb::init<const std::string &>(), "linefit ground segmentation constructor, with toml file as param file input.")
        .def("run", [](GroundSegmentation& self, const nb::ndarray<double>& array) {
            if (array.ndim() != 2 || array.shape(1) != 3) {…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kin-Zhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants