You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to take in a py::memoryview as a parameter to a function and I try to bind the function to my module but I keep getting a deleted function error under the argument loader constructor during compilation.
I've provided a minimal code where the error comes up. The goal of my binding code is to fill a buffer that's created in C++ in Python without copy.
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
int ex(py::memoryview buffer) { return 0; }
PYBIND11_MODULE(mpi_ex, m) {
m.def("ex",&ex, "Example test for py::memoryview");
}
The error message is as follows using gcc/11.2.0 and pybind11/2.8.1
In file included from /users/coorak/pybind_mpi/memoryview_test.cpp:1:
/opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/pybind11.h: In instantiation of 'void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = int (*&)(pybind11::memoryview); Return = int; Args = {pybind11::memoryview}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling, char [32]}]':
/opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/pybind11.h:92:19: required from 'pybind11::cpp_function::cpp_function(Return (*)(Args ...), const Extra& ...) [with Return = int; Args = {pybind11::memoryview}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling, char [32]}]'
/opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/pybind11.h:1012:22: required from 'pybind11::module_& pybind11::module_::def(const char*, Func&&, const Extra& ...) [with Func = int (*)(pybind11::memoryview); Extra = {char [32]}]'
/users/coorak/pybind_mpi/memoryview_test.cpp:44:10: required from here
/opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/pybind11.h:211:21: error: use of deleted function 'pybind11::detail::argument_loader<pybind11::memoryview>::argument_loader()'
211 | cast_in args_converter;
| ^~~~~~~~~~~~~~
In file included from /opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/attr.h:13,
from /opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/pybind11.h:13,
from /users/coorak/pybind_mpi/memoryview_test.cpp:1:
/opt/scorec/spack/v0181_2/install/linux-rhel7-x86_64/gcc-7.4.0/py-pybind11-2.8.1-7m3qjw5ijpih6coejwhzsstqrumztmvy/include/pybind11/cast.h:1163:7: note: 'pybind11::detail::argument_loader<pybind11::memoryview>::argument_loader()' is implicitly deleted because the default definition would be ill-formed:
1163 | class argument_loader {
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to take in a
py::memoryview
as a parameter to a function and I try to bind the function to my module but I keep getting a deleted function error under the argument loader constructor during compilation.I've provided a minimal code where the error comes up. The goal of my binding code is to fill a buffer that's created in C++ in Python without copy.
The error message is as follows using gcc/11.2.0 and pybind11/2.8.1
Beta Was this translation helpful? Give feedback.
All reactions