From 8229722dc5699a0ccc10ccdc1878346b382d88e8 Mon Sep 17 00:00:00 2001 From: Ved Patwardhan <54766411+VedPatwardhan@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:35:51 +0530 Subject: [PATCH] Fixed failing ivy test for randint by reverting recent changes and adjusting typecasting (#10592) --- ivy/functional/backends/torch/random.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ivy/functional/backends/torch/random.py b/ivy/functional/backends/torch/random.py index e42fc5505b7fb..7d5509a924ad4 100644 --- a/ivy/functional/backends/torch/random.py +++ b/ivy/functional/backends/torch/random.py @@ -104,14 +104,13 @@ def randint( ) -> torch.Tensor: if not dtype: dtype = ivy.default_int_dtype() - if not shape: - shape = (1,) dtype = ivy.as_native_dtype(dtype) _randint_check_dtype_and_bound(low, high, dtype) shape = _check_bounds_and_get_shape(low, high, shape) + rand_range = high - low if seed: torch.manual_seed(seed) - return torch.randint(low=low, high=high, size=shape, device=device, dtype=dtype) + return (torch.rand(shape, device=device) * rand_range + low).to(dtype) def seed(*, seed_value: int = 0) -> None: