Make TernarySelectOp immune to const differences.

See merge request libeigen/eigen!2058

Co-authored-by: Rasmus Munk Larsen <rmlarsen@google.com>
This commit is contained in:
Rasmus Munk Larsen
2025-11-04 21:42:32 +00:00
parent 71703a9816
commit 63fc0bc8c1
2 changed files with 3 additions and 2 deletions

View File

@@ -21,7 +21,8 @@ namespace internal {
template <typename ThenScalar, typename ElseScalar, typename ConditionScalar>
struct scalar_boolean_select_op {
static constexpr bool ThenElseAreSame = is_same<ThenScalar, ElseScalar>::value;
static constexpr bool ThenElseAreSame =
is_same<std::remove_const_t<ThenScalar>, std::remove_const_t<ElseScalar>>::value;
EIGEN_STATIC_ASSERT(ThenElseAreSame, THEN AND ELSE MUST BE SAME TYPE)
using Scalar = ThenScalar;
using result_type = Scalar;

View File

@@ -789,7 +789,7 @@ struct TensorEvaluator<const TensorSelectOp<IfArgType, ThenArgType, ElseArgType>
template <int LoadMode, bool UseTernary = TernaryPacketAccess, std::enable_if_t<!UseTernary, bool> = true>
EIGEN_DEVICE_FUNC PacketReturnType packet(Index index) const {
Scalar arr[PacketSize];
std::remove_const_t<Scalar> arr[PacketSize];
EIGEN_UNROLL_LOOP
for (Index i = 0; i < PacketSize; ++i) {
arr[i] = m_condImpl.coeff(index + i) ? Scalar(-1) : Scalar(0);