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

transpose op code behavior mismatch with comments in xla #50662

Open
mingting opened this issue Jul 8, 2021 · 1 comment
Open

transpose op code behavior mismatch with comments in xla #50662

mingting opened this issue Jul 8, 2021 · 1 comment
Assignees
Labels
comp:xla XLA stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 1.15 for issues seen on TF 1.15 type:bug Bug

Comments

@mingting
Copy link

mingting commented Jul 8, 2021

tensorflow 1.15.5
https://github.com/tensorflow/tensorflow/blob/v1.15.5/tensorflow/compiler/xla/service/shape_inference.cc#L2740

  // Permute(dimensions,input) computes output[dimensions[i]]=input[i]. However,
  // we need output[i]=input[dimensions[i]] which is
  // Permute(Inverse(dimensions),input).
  return ShapeUtil::PermuteDimensions(InversePermutation(dimensions), operand);

https://github.com/tensorflow/tensorflow/blob/v1.15.5/tensorflow/compiler/xla/util.h#L340

// Applies `permutation` on `input` and returns the permuted array.
// For each i, output[permutation[i]] = input[i].
//
// Precondition:
// 1. `permutation` is a permutation of 0..permutation.size()-1.
// 2. permutation.size() == input.size().
template <typename Container>
std::vector<typename Container::value_type> Permute(
    absl::Span<const int64> permutation, const Container& input) {
  using T = typename Container::value_type;
  absl::Span<const T> data(input);
  CHECK(IsPermutation(permutation, data.size()));
  std::vector<T> output(data.size());
  for (size_t i = 0; i < permutation.size(); ++i) {
    output[permutation[i]] = data[i];
  }
  return output;
}

my question is
accoding to the comments, if using inverse permutation, we should use output[i]=input[dimensions[i]].
but, code still use output[dimensions[i]]=input[i].

seems like a bug or mismatch?
I checked latest code, this is still there, but inverse moved to other place.
so I used 1.15.5, as the inverse code is together with permute.

BR.
Mingting

@mingting
Copy link
Author

mingting commented Jul 8, 2021

@hawkinsp can you help to check this?

@tilakrayal tilakrayal added TF 1.15 for issues seen on TF 1.15 comp:xla XLA labels Jul 8, 2021
@tilakrayal tilakrayal assigned ymodak and unassigned tilakrayal Jul 8, 2021
@ymodak ymodak added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Jul 9, 2021
@ymodak ymodak removed their assignment Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:xla XLA stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 1.15 for issues seen on TF 1.15 type:bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants