This bugzilla service is closed. All entries have been migrated to
Bug 1171 - Add Static assertion while assigning to rank zero reductionOperation output
Summary: Add Static assertion while assigning to rank zero reductionOperation output
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Tensor (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Feature Request
Assignee: Nobody
Depends on:
Reported: 2016-02-22 14:26 UTC by Abhijit
Modified: 2019-12-04 15:27 UTC (History)
5 users (show)


Description Abhijit 2016-02-22 14:26:02 UTC
Currently if a programmer mistakes a call like

 Eigen::Tensor<double, 0> max = some_tensor.maximum();

to something like:

 Eigen::Tensor<double, 1> max = some_tensor.maximum();

the code crashes in runtime. It will be nice to have a static assertion here.
Comment 1 Benoit Steiner 2016-02-22 17:16:01 UTC
I agree that a static assertion would be helpful. Unfortunately that would break TensorFlow, which tends to write things such as:

Tensor<float, 1> a;
Tensor<float, 2> b;
if (expected_rank == 1) {
  a = someexpression;
} else if (expected_rank == 2) {
  b = someexpression;

A static assertion would always be triggered by such a pattern, so we'd need to rework tensorflow before introducing the static assertion.

By the way, there is a debug assertion that checks the dimensions match when the assignment is evaluated.
Comment 2 Abhijit 2016-02-23 19:30:42 UTC
That makes sense, since TensorFlow has a lot of audience which might even include me in future when I get time to move my stuff from Caffe.

Is there already a issue in TensorFlow for doing those assignments statically, since otherwise we might loose track.
Comment 3 Nobody 2019-12-04 15:27:27 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.