This bugzilla service is closed. All entries have been migrated to
Bug 1772 - Tensor .select() with mixed tensor/scalar arguments
Summary: Tensor .select() with mixed tensor/scalar arguments
Alias: None
Product: Eigen
Classification: Unclassified
Component: Tensor (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Feature Request
Assignee: Nobody
Depends on:
Reported: 2019-11-05 14:24 UTC by Tobias Wood
Modified: 2019-12-04 18:54 UTC (History)
4 users (show)


Description Tobias Wood 2019-11-05 14:24:36 UTC
As discussed on the mailing list, the following program does not compile:

#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_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 because the second argument is a scalar.

Further notes from Christoph:

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());
Comment 1 Nobody 2019-12-04 18:54:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.