Returns whether transposing would be a no-op; whether input has rank < 2 or the permutation is the identity permutation.
| 309 | // Returns whether transposing would be a no-op; whether input has rank < 2 or |
| 310 | // the permutation is the identity permutation. |
| 311 | bool ShouldTranspose(const TensorShape& input_shape, |
| 312 | const std::vector<int>& permutation) { |
| 313 | if (input_shape.dims() < 2) return false; |
| 314 | for (int i = 0; i < permutation.size(); ++i) { |
| 315 | if (permutation[i] != i) return true; |
| 316 | } |
| 317 | return false; |
| 318 | } |
| 319 | |
| 320 | // Transpose the input given a permutation. Returns a reference to the input if |
| 321 | // transposing is not necessary. |
no test coverage detected