Re: [eigen] Tensor .select() with mixed tensor/scalar arguments
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: Re: [eigen] Tensor .select() with mixed tensor/scalar arguments
• From: Rasmus Munk Larsen <rmlarsen@xxxxxxxxxx>
• Date: Tue, 5 Nov 2019 10:59:27 -0800
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=MjznjM/QWbevP6iDr+HjxBxVLEfve+zlS0Eoef/stzE=; b=AyzMYOJGqOC7rUGYa03UhXM+yCoiVrfwfdccK0vI6hb0BP6kQAEux95M7vTXpZ89nA nPOLD+DsY/ODaGNgroaMpSTTA5D0aZW5qahQtA2KlDa0e4bLbGLsYXY8EM5agTpMXZbR DJGALQ5h3HMzthLjwP034EDvo8/GUFltNBvUyD4k710N8P6xGk0OI/cW5fSNVA3N/QcU MP19s37L2i8KYa70IhwyGJ/3Q/dr3StZM7GNn5A2m+8k3rYuy71X4jPWhw3GIBGyvdeh h/gocDuNeu9k3Y/I0HQD367iRJdWLfL1IbPu0FU+w4XuatTmnBTdDxJYz9JdaNLEGOsZ XuDw==

Yes, select is an operator on tensors. You can write something like

ft_result = (ft_A < 0.5f).select(ft_A, ft_A.constant(0.0f));

or you/we could add some syntactic sugar to transform your original _expression_ into this.

On Tue, Nov 5, 2019 at 3:13 AM Wood, Tobias <tobias.wood@xxxxxxxxx> wrote:

Hello,

The following simplified program does not compile with Eigen HEAD:

#include <unsupported/Eigen/CXX11/Tensor>

int main(const int argcconst char *const argv[])

{

Eigen::Tensor<float2ft_A(24), ft_B(24), ft_result(24);

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

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/