Re: [eigen] Tensor .select() with mixed tensor/scalar arguments |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Tensor .select() with mixed tensor/scalar arguments
- From: Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 5 Nov 2019 14:44:52 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-bremen.de; s=2019; t=1572961493; i=@uni-bremen.de; bh=wE/8MowGKZktQir1kLP/Zfxy10WjyTjbvZBVCjdnrjc=; h=To:References:From:Date:In-Reply-To; b=huI3og95ZSg4RCyfn9tsW7h0m9EdHyxj58whsSyrQKyUzP46N0JJf8XZqGWT/pGP/ PDPlYguKcAOzTtLWBGCZoOt3MjzHDDu1FEIudK1HkPDPkCmvournHEKR6bJkPCzGGB utUW3dRI1tnOdNaRW1Y+Z3vWfdZS3rZZKj01/O8T2QV/1A+YlIy64RknaNm4o4N5Kf IhE3TtXd7Sz+9QYaDpX44yOOpVV3xgcjv090ljRyByOLDxDGpQQyL1qnv3r48P8Tvv GScbxkHjFciIPfLkmT7+z3AXm/1Ev/xg0WlScJrmwnbD2azg0erMhqePQfDHTHIxRX eAoAjse02Tu2w==
Your code works fine with `Eigen::ArrayXXf` instead of
`Eigen::Tensor<float,2>`, so making this work for Tensor as well would
not be a bad idea. Feel free to open a bug for that.
As a workaround, you can write:
ft_result = (ft_A < 0.5f).select(ft_A, ft_A.constant(0.0f));
This is also inconsistent with the Array-API, where you would need to
write (instead of `ft_A.constant(0.0f)`):
ArrayXXf::Constant(0.0f, ft_A.rows(), ft_A.cols());
Cheers,
Christoph
On 05/11/2019 12.12, Wood, Tobias wrote:
Hello,
The following simplified program does not compile with Eigen HEAD:
#include <unsupported/Eigen/CXX11/Tensor>
int main(const int argc, const char *const argv[])
{
Eigen::Tensor<float, 2> ft_A(2, 4), ft_B(2, 4), ft_result(2, 4);
ft_A.setRandom();
ft_B.setZero();
ft_result = (ft_A < 0.5f).select(ft_A, ft_B);
ft_result = (ft_A < 0.5f).select(ft_A, 0.f);
}
The first call to ft_result compiles fine, but the second does not. The first line of compile errors is:
Eigen/src/Core/util/ForwardDeclarations.h:23:47: error: implicit instantiation of undefined template 'Eigen::internal::traits<float>
So it looks to me like Eigen tries to treat the 0.f as an Eigen tensor, rather than as the scalar type.
Does this count as a bug and if so should I open a bug on the tracker? I looked at trying to fix it myself but sadly this kind of Eigen issue is out of my league.
Best wishes,
Toby
--
Dr.-Ing. Christoph Hertzberg
Besuchsadresse der Nebengeschäftsstelle:
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Postadresse der Hauptgeschäftsstelle Standort Bremen:
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-Straße 1
28359 Bremen, Germany
Tel.: +49 421 178 45-4021
Zentrale: +49 421 178 45-0
E-Mail: christoph.hertzberg@xxxxxxx
Weitere Informationen: http://www.dfki.de/robotik
-------------------------------------------------------------
Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
Trippstadter Strasse 122, D-67663 Kaiserslautern, Germany
Geschäftsführung:
Prof. Dr. Jana Koehler (Vorsitzende)
Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats:
Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
-------------------------------------------------------------