Repository: ivy-llc/ivy

Issue:
No value for argument `shape` in function calls.
In the following function calls, the `shape` argument is not passed.
https://github.com/unifyai/ivy/blob/79de1aaeb45883e8a9a3119caa749dfac39d9b34/ivy/functional/frontends/paddle/tensor/tensor.py#L231
https://github.com/unifyai/ivy/blob/79de1aaeb45883e8a9a3119caa749dfac39d9b34/ivy/functional/frontends/torch/tensor.py#L145

From the if-else conditions above, these function calls happen when both `shape` and `args` are `None`.
I am not sure whether to just add the shape argument in the function calls and pass `None` as the argument like this:

`return paddle_frontend.reshape(self, shape)`


Discussion:
@vedpatwardhan Please look into this issue when you are free, I would be happy to make a PR if you think this needs to be fixed.
I am not sure whether to just add the `shape` argument in the function calls and pass `None` as the argument like this:
`return paddle_frontend.reshape(self, shape)`
Hey @Sai-Suraj-27, thanks for the suggestion, but wouldn't it be the same as not passing `shape`? Because `torch.reshape(tensor)` and `torch.reshape(tensor, None)` both throw an error, so ideally our instance method signature should be like [this](https://pytorch.org/docs/stable/generated/torch.Tensor.reshape.html), which was actually the case before until [this](https://github.com/unifyai/ivy/commit/d9244aa3c8fa7be299ed60f67fc7919e0ac9b558) commit. @AnnaTz do you remember why that change was made by any chance? No worries if not ofc, but would be great to find out why we did that 😄
> Hey @Sai-Suraj-27, thanks for the suggestion, but wouldn't it be the same as not passing `shape`? Because `torch.reshape(tensor)` and `torch.reshape(tensor, None)` both throw an error, so ideally our instance method signature should be like [this](https://pytorch.org/docs/stable/generated/torch.Tensor.reshape.html), which was actually the case before until [this](https://github.com/unifyai/ivy/commit/d9244aa3c8fa7be299ed60f67fc7919e0ac9b558) commit. @AnnaTz do you remember why that change was made by any chance? No worries if not ofc, but would be great to find out why we did that 😄

Yes, `torch.reshape(tensor)` and `torch.reshape(tensor, None)` both will throw an error. So, I was not sure how to fix this.
> Hey @Sai-Suraj-27, thanks for the suggestion, but wouldn't it be the same as not passing `shape`? Because `torch.reshape(tensor)` and `torch.reshape(tensor, None)` both throw an error, so ideally our instance method signature should be like [this](https://pytorch.org/docs/stable/generated/torch.Tensor.reshape.html), which was actually the case before until [this](https://github.com/unifyai/ivy/commit/d9244aa3c8fa7be299ed60f67fc7919e0ac9b558) commit. @AnnaTz do you remember why that change was made by any chance? No worries if not ofc, but would be great to find out why we did that 😄

This was updated because the original `torch.Tensor.reshape` is overloaded to support both `torch.Tensor.reshape(*shape)` and `torch.Tensor.reshape(shape)` calls (even though it doesn't seem to be mentioned in the docs). 

I think that instead of calling `reshape(self)` in the case neither `args` nor `shape` are provided, we should just raise an error (like we do in case both of them are provided). 
@AnnaTz so, can we do something like this?
`raise ValueError("reshape() got no values for argument 'shape'")`
> This was updated because the original `torch.Tensor.reshape` is overloaded to support both `torch.Tensor.reshape(*shape)` and `torch.Tensor.reshape(shape)` calls (even though it doesn't seem to be mentioned in the docs).
> 
> I think that instead of calling `reshape(self)` in the case neither `args` nor `shape` are provided, we should just raise an error (like we do in case both of them are provided).

Yep sounds good! Could you please request @AnnaTz's review on the PR you create? Thanks @Sai-Suraj-27 😄


Resolving patch:
diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py
--- a/ivy/functional/frontends/paddle/tensor/tensor.py
+++ b/ivy/functional/frontends/paddle/tensor/tensor.py
@@ -235,7 +235,8 @@ def reshape(self, *args, shape=None):
                 return paddle_frontend.reshape(self, shape)
             else:
                 return paddle_frontend.reshape(self, args)
-        return paddle_frontend.reshape(self)
+        else:
+            raise ValueError("reshape() got no values for argument 'shape'")
 
     def dim(self):
         return self.ivy_array.ndim
diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py
--- a/ivy/functional/frontends/torch/tensor.py
+++ b/ivy/functional/frontends/torch/tensor.py
@@ -142,7 +142,8 @@ def reshape(self, *args, shape=None):
                 return torch_frontend.reshape(self, shape)
             else:
                 return torch_frontend.reshape(self, args)
-        return torch_frontend.reshape(self)
+        else:
+            raise ValueError("reshape() got no values for argument 'shape'")
 
     @with_unsupported_dtypes({"2.1.1 and below": ("bfloat16",)}, "torch")
     @with_unsupported_dtypes({"2.5.1 and below": ("float16",)}, "paddle")


Test patch: