Skip to content
Permalink
Browse files Browse the repository at this point in the history
Make Transpose's shape inference function validate that negative `per…
…m` values are within the tensor's rank.

PiperOrigin-RevId: 403252853
Change-Id: Ia6b31b45b237312668bb31c2c3b3c7bbce2d2610
  • Loading branch information
penpornk authored and tensorflower-gardener committed Oct 15, 2021
1 parent 042dc3b commit c79ba87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tensorflow/core/ops/array_ops.cc
Expand Up @@ -168,7 +168,7 @@ Status TransposeShapeFn(InferenceContext* c) {

for (int32_t i = 0; i < rank; ++i) {
int64_t in_idx = data[i];
if (in_idx >= rank) {
if (in_idx >= rank || in_idx <= -rank) {
return errors::InvalidArgument("perm dim ", in_idx,
" is out of range of input rank ", rank);
}
Expand Down

0 comments on commit c79ba87

Please sign in to comment.