Layout optimizer and transposing scalars #68488
Open
+3
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running this tutorial https://www.tensorflow.org/tutorials/images/classification, I am observing a run-time error:
E tensorflow/core/grappler/optimizers/meta_optimizer.cc:961] layout failed: INVALID_ARGUMENT: Size of values 0 does not match size of permutation 4 @ fanin shape inStatefulPartitionedCall/sequential_2_1/dropout_1/stateless_dropout/SelectV2-2-TransposeNHWCToNCHW-LayoutOptimizer
The error occurs because grappler's layout optimizer encounters this code
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/nn_ops.py#L5809
where keep_mask and ret are both rank 4, but zero_tensor is rank 0. Since this is a legal input for array_ops.where_v2, the fault lies in the layout optimizer. Supplied fix preventsit from flagging an error when it needs to propagate a transpose to a scalar input.