Re: [eigen] Tensor .select() with mixed tensor/scalar arguments |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: "eigen@xxxxxxxxxxxxxxxxxxx" <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Tensor .select() with mixed tensor/scalar arguments
- From: "Wood, Tobias" <tobias.wood@xxxxxxxxx>
- Date: Tue, 5 Nov 2019 14:26:39 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kcl.ac.uk; dmarc=pass action=none header.from=kcl.ac.uk; dkim=pass header.d=kcl.ac.uk; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qvBBCzaCcYlSTO7CBdUMUbxNX22JOJpa8NYTAIa+2F4=; b=NzT2T+WiWuNVfC8MzHDrwW3hcL4qoE77URVpz0gYcNsvN+YF0SmMy3+snwUocDtDloOdJaKlI0GLhK4N6O3hsDqu0u2uCurUrcaJIVh+gnVUTZrXmGMfXBrwX1SbQjvY7QnZrjBNXmd/bDdA8xix8AADJTNTITpkfS98miW4OMfqON8Ygm15yRVofPLY9DyNtCpMLAWdyVJp099jTZEJMJUrlIQe+yGciXeEpgZxEnUZr/vGSvBqkCJ/TxgNS2eVf6BlCPWvlwGOr5OzXfs6m3j8gJssATAsdEUOM40SjYN6VcT1LczdKsc7X0osCD63c2AGpAM+VWyUNcm9eFJ/0Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJxiEfw+rF+xLhGi8gz4P2dyO4nawdlhbDSipY1wr28QjSErUUhj0aOFGYvOWzQ7r6G9NkdjGNyjKJ7JexJk8x+/6AvU88bKWqXWrpGecK+a7157MVaxW/S+pgmTDcb/pnv8/zBNledjW62aE6v57sUURqQCs56NAiRc5AOSL5kz+I8QQRzxOp/YEkD1HyCkdaaUNjFN0e5PTLkGm1jWxO0ugJlNXWZ0eo5r/QFERfKAD9mlU1Gcp+HRn3DogNqdHMR0Vh1/W2HP5PY2fkrifIE/Qiv5qNRX0tCoTHAsBkVavkcZ+t2VfnUDWg3f1Bvl3+mfnDo39OUjVvtEUqK3Nw==
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=tobias.wood@xxxxxxxxx;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kcl.ac.uk; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qvBBCzaCcYlSTO7CBdUMUbxNX22JOJpa8NYTAIa+2F4=; b=Tp/oYBr6j+2Fo91QlY2SOHYkPiAL3ucouVwkrOdPZ19BPRT6QlyH26eTGTrSkpr7aV3/XMwekiOMf3ujfMt8WFThB87xsuQRp08HHD8ChLmvQi4LWlUaHYFttEFZd0KX0V0wAlTDQtdoOj3FApJDHZwYHytNssTHPrv2yuIjuts=
- Thread-index: AQHVk8nqzypvaQT6ME2g/sDbGMLaXqd8ltIAgAALrIA=
- Thread-topic: [eigen] Tensor .select() with mixed tensor/scalar arguments
Thanks for the .constant() workaround!
I've opened a bug.
Toby
On 05/11/2019, 13:45, "Christoph Hertzberg" <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dfki.de%2Frobotik&data=01%7C01%7Ctobias.wood%40kcl.ac.uk%7C7683ce1039fa46a4754608d761f66efe%7C8370cf1416f34c16b83c724071654356%7C0&sdata=XMwSgtNr08DydJTQCWQQh94yxKoTrQ6Rp2%2FZoNgL0NI%3D&reserved=0
-------------------------------------------------------------
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
-------------------------------------------------------------