Broken custom visitor implementation
Summary
I am trying to upgrade drake library to latest eigen. The library creates custom visitor here to check if expression is affine.
This eigen MR seems to have broken the custom visitor. It suggests a way to put LinearAccess = false. However, functor_traits seems to have no LinearAccess enum which is causing compile error.
Maybe there is something missing in my understanding of the usage of functor_traits structs. Please suggest a fix which allows the code to compile, albeit with performance hit as suggested in the eigen MR.
Environment
- Operating System : Linux
- Architecture : AMD64
- Eigen Version : commit hash 6266d430ccaa8b0cf826a42e5d1d9686eaa3382a
-
Compiler Version : 20.1.3 (++20250415115000+9420327ad768-1
exp120250415235030.102) - Compile Flags : -O3 -march=native
- Vector Extension :
Minimal Example
Steps to reproduce
What is the current bug behavior?
Code gives compile error as shown below
What is the expected correct behavior?
Code should compiles
Relevant logs
ERROR: /home/base/userid/.cache/bazel/_bazel_userid/461bed39f360366009114445d0ea2ca1/external/drake/common/symbolic/BUILD.bazel:172:17: Compiling common/symbolic/decompose.cc failed: (Exit 1): gcc-11 failed: error executing CppCompile command (from target @@drake//common/symbolic:_polynomial_compiled_cc_impl) /usr/bin/gcc-11 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 129 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/eigen3/Eigen/Core:353,
from external/eigen3/Eigen/Dense:1,
from bazel-out/k8-opt-prod/bin/external/drake/common/_virtual_includes/essential/drake/common/eigen_types.h:14,
from bazel-out/k8-opt-prod/bin/external/drake/common/symbolic/_virtual_includes/_polynomial_compiled_cc_impl/drake/common/symbolic/decompose.h:8,
from external/drake/common/symbolic/decompose.cc:1:
external/eigen3/Eigen/src/Core/Visitor.h: In instantiation of 'constexpr const bool Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>::LinearAccess':
external/eigen3/Eigen/src/Core/Visitor.h:340:20: required from 'constexpr const int Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>::VectorOps'
external/eigen3/Eigen/src/Core/Visitor.h:345:35: required from 'constexpr const int Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>::TotalOps'
external/eigen3/Eigen/src/Core/Visitor.h:348:70: required from 'constexpr const bool Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>::Unroll'
external/eigen3/Eigen/src/Core/Visitor.h:349:38: required from 'constexpr const int Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>::UnrollCount'
external/eigen3/Eigen/src/Core/Visitor.h:351:9: required from 'struct Eigen::internal::visit_impl<Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >, drake::symbolic::{anonymous}::IsAffineVisitor, false>'
external/eigen3/Eigen/src/Core/Visitor.h:384:12: required from 'void Eigen::DenseBase<Derived>::visit(Visitor&) const [with Visitor = drake::symbolic::{anonymous}::IsAffineVisitor; Derived = Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >]'
external/drake/common/symbolic/decompose.cc:72:10: required from here
external/eigen3/Eigen/src/Core/Visitor.h:335:77: error: 'LinearAccess' is not a member of 'Eigen::internal::functor_traits<drake::symbolic::{anonymous}::IsAffineVisitor>'
335 | Evaluator::LinearAccess && static_cast<bool>(functor_traits<Visitor>::LinearAccess);
| ^~~~~~~~~~~~