New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tf.case doesn't preserve shape information #3334
Comments
Assigning to @yuanbyu to take a look (although he's out of office currently). |
This is what case originally looked like (look at the git history for the file). Unfortunately, this has the bad side effect of always executing at least two nodes (default and the one that evaluated to true). Even if the default node was not actually returned, it was still executed and as a result may have had possible side effects. Feel free to change the code as you suggested and you'll see a unit test in control_flow_ops start failing. The real solution is to factor out cond() into a sequence of internal _if_then; which can be used for case as well. |
@yuanbyu another reason to split up cond/case into if_then type statements? |
This is on the backburner for a bit; sorry. No updates on when it'll be done. |
ETA on fix? I'm currently nestling |
The fix for this one is more involved than originally anticipated. Will update the issue with an ETA once we have an initial fix. |
Ping! Is there work going on to fix this issue? |
It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly. |
Nagging Assigneee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks! |
tf.case is a python implementation of a case statement using tf.cond, but unlike cond it doesn't preserve shape information when executing. This is because of this little snippet:
The op works by evaluating a series of predicates (including a predicate for the default value) but it starts off with an empty object. The empty object seems to be designed to pass on correct shape and type information but it fails to do so in my use case. I recommend changing this code to read:
This removes the need not only for creating a dummy empty op, but also removes the need to create a separate predicate for the default op, simplifying the whole op by about 18 lines of code.
The text was updated successfully, but these errors were encountered: