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
When I try to mix <pybind11/eigen.h> and <autodiff/reverse/var/eigen.h> I get the following error, however it works fine with <autodiff/forward/real/eigen.h>. Is there a known way to mix reverse with pybind11/eigen ?
Error:
In file included from /opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/eigen/matrix.h:12,
from /opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/eigen.h:12,
from /home/amit/Tutorials/autodiff/example_pybind.cpp:6:
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/numpy.h: In instantiation of ‘struct pybind11::detail::npy_format_descriptor<autodiff::detail::Variable<double>, void>’:
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/eigen/matrix.h:224:40: required from ‘constexpr const auto pybind11::detail::EigenProps<Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1> >::descriptor’
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/eigen/matrix.h:388:27: required from ‘constexpr const auto pybind11::detail::type_caster<Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>, void>::name’
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/cast.h:1404:56: required from ‘constexpr const auto pybind11::detail::argument_loader<MyFunc*, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&>::arg_names’
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/pybind11.h:291:31: required from ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = MyFunc; Arg = {Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling}]::<lambda(MyFunc*, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&)>; Return = void; Args = {MyFunc*, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling}]’
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/pybind11.h:109:9: required from ‘pybind11::cpp_function::cpp_function(Return (Class::*)(Arg ...), const Extra& ...) [with Return = void; Class = MyFunc; Arg = {Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling}]’
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/pybind11.h:1568:22: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = void (MyFunc::*)(Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<autodiff::detail::Variable<double>, -1, 1, 0, -1, 1>&); Extra = {}; type_ = MyFunc; options = {PyFunc}]’
/home/amit/Tutorials/autodiff/example_pybind.cpp:49:29: required from here
/opt/mambaforge/mambaforge/envs/colabfit/include/pybind11/numpy.h:1420:37: error: static assertion failed: Attempt to use a non-POD or unimplemented POD type as a numpy dtype
1420 | static_assert(is_pod_struct<T>::value,
| ^~~~~
make[2]: *** [CMakeFiles/example_pybind11.dir/build.make:63: CMakeFiles/exam
C++ file:
// C++ includes
#include<iostream>// Pybind11 includes
#include<pybind11/pybind11.h>
#include<pybind11/eigen.h>
#include<pybind11/stl.h>
#include<pybind11/numpy.h>// autodiff include// << This does not compile >>
#include<autodiff/reverse/var.hpp>
#include<autodiff/reverse/var/eigen.hpp>typedef autodiff::VectorXvar vector_kind;
// << This compiles >>//#include <autodiff/forward/real.hpp>//#include <autodiff/forward/real/eigen.hpp>//typedef autodiff::VectorXreal vector_kind;usingnamespaceautodiff;// Base virtual classclassMyFunc {
public:virtualvoidf(vector_kind& x, vector_kind& y) = 0;};
// Concrete classclassMyFunc1 : publicMyFunc {
public:voidf(vector_kind& x, vector_kind& y) override { y = 2 * x;}};
// Pybind11 TrampolineclassPyFunc : publicMyFunc {
public:using MyFunc::MyFunc;
voidf(vector_kind& x, vector_kind& y) override {
PYBIND11_OVERLOAD_PURE(void, MyFunc, f, x, y);
}
};
PYBIND11_MODULE(example_pybind, m) {
pybind11::class_<MyFunc, PyFunc>(m, "MyFunc")
.def(pybind11::init<>())
.def("f", &MyFunc::f);
}
When I try to mix
<pybind11/eigen.h>
and<autodiff/reverse/var/eigen.h>
I get the following error, however it works fine with<autodiff/forward/real/eigen.h>
. Is there a known way to mix reverse with pybind11/eigen ?Error:
C++ file:
CMAKE file:
The text was updated successfully, but these errors were encountered: