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

tolist #21303

Closed
wants to merge 11 commits into from
Closed

tolist #21303

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ env.bak/
venv.bak/
ivy_dev/
*venv/
venv*
venv*
ivy_dev
Sanchay-T marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 4 additions & 2 deletions .idea/ivy.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/runConfigurations/_template__of_py_test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ivy/functional/frontends/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def split(x, num_or_sections, axis=0, name=None):
return ivy.split(x, num_or_size_splits=num_or_sections, axis=axis)


@with_unsupported_dtypes(
{"2.5.1 and below": ("int16", "complex64", "complex128")},
"paddle",
)
@to_ivy_arrays_and_back
def tolist(x):
return ivy.tolist(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, ivy.tolist has no implementation in the functional layer so this won't work. Have you tested this locally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No , I had trouble checking it locally , as when I imported the file on top and ran , it kept on looks at the ivy package that was installed through req I guess

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just delete this all and start again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will starting over again help? You need to implement the corresponding function in ivy's functional layer and maybe in the backend too. Please read through ivy's documentation to get an understanding on this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go through the documentation once again , but I understood the paddle implementation. I cannot seem to find the implementation of tolist in ivy. Maybe I am wrong and sorry for troubling you. But I know that my function will take the tensor as an input and the output should be the list. But is there something inbuilt?
This is the paddle paddle documentation:
image

And this is what I found in the source code on github of Paddle paddle :
image

I still dont understand the tolist() declaration. It would help me a lot if you can somewhat guide me?
Thankyou

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will say the same thing again, go through ivy's documentation to understand what you are missing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes went thorough the entire documentation , understood what I was doing wrong. Thankyou. After I push the corrected code here , is the octernship task complete. I didnt understand where to exactly create a pr , in the webinar on youtube they said , there is another repo that will be created by the ivy team for me , and there I have to push

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also is the issue still allocated to me how do I check , because in the documentation it was mentioned 7 days



@with_unsupported_dtypes(
{"2.5.1 and below": ("float16", "bfloat16", "int8", "int16")},
"paddle",
Expand Down Expand Up @@ -132,3 +141,8 @@ def gather(params, indices, axis=-1, batch_dims=0, name=None):
@to_ivy_arrays_and_back
def roll(x, shifts, axis=None, name=None):
return ivy.roll(x, shifts, axis=axis)


@to_ivy_arrays_and_back
def to_list(x):
return x.tolist()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this extra function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was pasted again at the end by mistake , I corrected it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed again. @vaithak

Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,33 @@ def test_paddle_roll(
shifts=shift,
axis=axis,
)


# tolist
@handle_frontend_test(
fn_tree="paddle.tensor.manipulation.tolist",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
min_num_dims=1,
max_num_dims=6,
),
)
def test_tolist(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
test_flags,
backend_fw,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
backend_to_test=backend_fw,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
x=x[0],
)