Skip to content

Commit

Permalink
[BugFix] Fixed Inappropriate Logical Expression (#16272)
Browse files Browse the repository at this point in the history
[BugFix] Fixed a comparison for splitting tensor

In the `tensor_split` method, there's a comparsion
that checks if the input tensor is zero-dimensional
or one-dimensional long tensor.

In the comparsion, there's a typo that converts
the shape of the tensor to a list and compares
against integer.

This commit fixes the bug by comapring the
length of the tensor against the integer.

Signed-off-by: fazledyn-or <ataf@openrefactory.com>
  • Loading branch information
fazledyn-or committed Dec 26, 2023
1 parent a050696 commit 1c45389
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,7 @@ def tensor_split(self, inputs, input_types):
)
raise AssertionError(msg)

if isinstance(inputs[1], torch.Tensor) and not (
list(inputs[1].shape) == [] or list(inputs[1].shape) == 1
):
if isinstance(inputs[1], torch.Tensor) and len(inputs[1].shape) not in [0, 1]:
msg = "indices_or_sections must be a zero-dimensional or one-dimensional long tensor"
raise AssertionError(msg)

Expand Down

0 comments on commit 1c45389

Please sign in to comment.