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

add fix for torch tensor reshape tests #10447

Merged

Conversation

clsandoval
Copy link
Contributor

@clsandoval clsandoval commented Feb 9, 2023

Closes #10426

Issue

I only included the relevant arguments for the sake of brevity. Essentially, method_all_as_kwargs_np expects a dict with a key/value pair corresponding to the relevant keyword/value. This would not happen here in the case that unpack_shape=True and shape=() as the shape passed to method_all_as_kwargs_np would remain a tuple.

def test_torch_instance_reshape(
    ...
    shape,
    unpack_shape,
    ...
):
    input_dtype, x = dtype_x
    if unpack_shape:
        method_flags.num_positional_args = len(shape) + 1
        shape = {}
        i = 0
        for x_ in shape:
            shape["x{}".format(i)] = x_
            i += 1
    else:
        shape = {
            "shape": shape,
        }
    helpers.test_frontend_method(
        ...
        method_all_as_kwargs_np=shape,
        ...
    )

Fix

I refactored the code to include this case.

    input_dtype, x = dtype_x
    shape = {
        "shape": shape,
    }
    if unpack_shape:
        method_flags.num_positional_args = len(shape["shape"]) + 1
        i = 0
        for x_ in shape["shape"]:
            shape["x{}".format(i)] = x_
            i += 1
    helpers.test_frontend_method(
        ...
        method_all_as_kwargs_np=shape,
        ...
    )

@ivy-leaves ivy-leaves added the PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist label Feb 9, 2023
@suvadityamuk
Copy link
Contributor

Hi, @clsandoval

Thank you for the Pull Request!
This looks good to me. Thanks for your contribution 🙂 !

@suvadityamuk suvadityamuk merged commit 998e274 into ivy-llc:master Feb 14, 2023
vedpatwardhan pushed a commit to vedpatwardhan/ivy that referenced this pull request Feb 17, 2023
….test.fix

add fix for torch tensor reshape tests
vedpatwardhan pushed a commit to vedpatwardhan/ivy that referenced this pull request Feb 23, 2023
….test.fix

add fix for torch tensor reshape tests
vedpatwardhan pushed a commit to vedpatwardhan/ivy that referenced this pull request Feb 26, 2023
….test.fix

add fix for torch tensor reshape tests
vedpatwardhan pushed a commit to vedpatwardhan/ivy that referenced this pull request Feb 26, 2023
….test.fix

add fix for torch tensor reshape tests
@clsandoval clsandoval deleted the torch.tensor.reshape.test.fix branch May 21, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix tensor.test_torch_instance_reshape
3 participants