From 1c4538947bed5b987530730a3a7be5632725c965 Mon Sep 17 00:00:00 2001 From: Ataf Fazledin Ahamed Date: Wed, 27 Dec 2023 03:19:17 +0600 Subject: [PATCH] [BugFix] Fixed Inappropriate Logical Expression (#16272) [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 --- python/tvm/relay/frontend/pytorch.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/tvm/relay/frontend/pytorch.py b/python/tvm/relay/frontend/pytorch.py index b02e59b2654b..54004c379d52 100644 --- a/python/tvm/relay/frontend/pytorch.py +++ b/python/tvm/relay/frontend/pytorch.py @@ -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)