Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ivy Failing Test: paddle - general.get_item #28050

Open
sgalpha01 opened this issue Jan 25, 2024 · 1 comment
Open

Fix Ivy Failing Test: paddle - general.get_item #28050

sgalpha01 opened this issue Jan 25, 2024 · 1 comment
Labels
Sub Task a sub task which is stemming from a ToDo list issue

Comments

@sgalpha01
Copy link
Contributor

ToDo - #27501
Sub-Task: Priority Open

@sgalpha01 sgalpha01 added the Sub Task a sub task which is stemming from a ToDo list issue label Jan 25, 2024
@sgalpha01
Copy link
Contributor Author

sgalpha01 commented Jan 25, 2024

This issue might be related to the test suite. It is throwing RuntimeError: (PreconditionNotMet) Tensor not initialized yet when DenseTensor::place() is called. whenever an empty array is passed, for example ivy.array([]). I did some debugging, and found that the error was coming inside the get_ret_and_flattened_np_array function, specifically in the ret = fn(*args, **kwargs) line. Interestingly, when I tried to replicate this error outside of pytest, it did not throw this error.

import paddle
from ivy_tests.test_ivy.helpers.pipeline_helper import BackendHandler

import ivy
from ivy.functional.backends.paddle.general import get_item

backend_to_test = "paddle"
args = [ivy.array([]), ()]
kwargs = {"copy": False}
fn = get_item

with BackendHandler.update_backend(backend_to_test) as ivy_backend:
    with ivy_backend.PreciseMode(False):
        ret = fn(*args, **kwargs)

I'm attaching the output of pytest ivy_tests/test_ivy/test_functional/test_core/test_general.py::test_get_item --verbose --backend paddle:
paddle_get_item.log

0danteh added a commit to 0danteh/ivy that referenced this issue Jan 25, 2024
It has identified a runtime issue where the `get_item` function raises a `RuntimeError` when an empty array is passed as an input. This error occurs under the specific condition when `ivy.array([])` is used as an argument, leading to an uninitialized tensor error within the Paddle backend.

This PR aims at introducing a check for empty arrays at the beginning of the `get_item` function. If the input array is empty, the function now returns an appropriately shaped and typed empty Paddle tensor, preventing the uninitialized tensor error. With this change, the `get_item` function can now safely handle empty array inputs without raising an error, ensuring consistent behavior and robustness. This fix also aligns with the expected behavior when using scalar boolean indices, where an empty tensor is returned if the boolean condition is False.
This change does not affect any existing functionality or performance for non-empty array inputs.

This fix is in response to the issue reported in [ivy-llc#28050] where users encountered runtime errors during testing scenarios involving empty arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sub Task a sub task which is stemming from a ToDo list issue
Projects
None yet
Development

No branches or pull requests

1 participant