Skip to content
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

Layout optimizer and transposing scalars #68488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekuznetsov139
Copy link
Contributor

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

    zero_tensor = constant_op.constant(0, dtype=x_dtype)
    ret = array_ops.where_v2(keep_mask, ret, zero_tensor)

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.

@google-ml-butler google-ml-butler bot added the size:XS CL Change Size: Extra Small label May 23, 2024
@google-ml-butler google-ml-butler bot requested a review from ezhulenev May 23, 2024 01:56
@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label May 23, 2024
@gbaned gbaned added the comp:grappler Grappler related issues label May 23, 2024
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation May 23, 2024
@@ -581,6 +581,9 @@ Status PermuteSingle(absl::string_view location,
absl::Span<const int> permutation, T* values) {
DCHECK(values != nullptr);
int permutation_size = permutation.size();
if (values->size() <= 1 || permutation_size <= 1) {
return absl::OkStatus();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is an error case, we shouldn't return OkStatus

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see that it is legal, it's just grappler that has an issue

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer May 23, 2024
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels May 23, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label May 23, 2024
@gbaned gbaned added ready to pull PR ready for merge process and removed awaiting review Pull request awaiting review ready to pull PR ready for merge process labels Jun 5, 2024
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:grappler Grappler related issues ready to pull PR ready for merge process size:XS CL Change Size: Extra Small
Projects
PR Queue
  
Approved by Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

4 participants