-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Beside use c++ graph directly, labels can be done so as well. Now all the labels are copied, e.g., from dict to std::map, but it is possible to share the memory without copying at all. Let's say we have a dict from string to np.array(float), now we convert it to std::vector by copying element by element. Moreover, std::vector does not support direct conversion without copying. There are several candidate way to fix this:
-
(recommended) use pybind, converting np array to py::vector (semi-altomatically), then either use py::vector directly in c++ to replace std::vector, or use a wrapper to convert it to eigen vector. I recommend the first one, cas then we can use to unified py::vector API to be compatibale with other new libs. pybind also support eigen and numpy natively.
-
np.ndarray + memoryview + Eigen::Map or expose Eigen api to python. This nees to write wrapper myself.
The point is, c++ API must be revised (mostly the ones related to AttrLabel) to support memory sharing as far as I know, so I'd rather use pybind once for all.