-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 reshape frontends.torch.indexing_slicing_joining_mutating_ops #2637
Add reshape frontends.torch.indexing_slicing_joining_mutating_ops #2637
Conversation
to frontends.torch.indexing_slicing_joining_mutating_ops
to test_frontends.test_indexing_slicing_joining_mutating_ops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! Thanks for contributing! As you chose reshape
as your frontend function to work on, please only make changes on that function and its tests without anything else, thanks!
|
oh! I see, yeah, please do each function in different PRs! I'll take a look at reshape and provide a review soon! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! Great work so far, there are a few changes required before it's good to go! Please request my review again when you're done! Thank you!
ivy/functional/frontends/torch/indexing_slicing_joining_mutating_ops.py
Outdated
Show resolved
Hide resolved
|
||
# reshape | ||
@given( | ||
xs_n_input_dtypes_n_unique_idx=_arrays_idx_n_dtypes(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use helpers.dtype_and_values
as unique idx is not needed, and set the argument available_dtypes
to:
available_dtypes=tuple(
set(ivy_np.valid_float_dtypes).intersection(
set(ivy_torch.valid_float_dtypes)
)
)
with_out, | ||
fw, | ||
): | ||
xs, input_dtypes, unique_idx = xs_n_input_dtypes_n_unique_idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once you've changed to use dtype_and_values
, there will only be two variables - dtype, x = ...
needed
fw, | ||
): | ||
xs, input_dtypes, unique_idx = xs_n_input_dtypes_n_unique_idx | ||
xs = [np.asarray(x, dtype=dt) for x, dt in zip(xs, input_dtypes)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep only np.asarray(x, dtype=...)
, extra square brackets for list casting is not required too
fw=fw, | ||
frontend="torch", | ||
fn_name="reshape", | ||
tensors=xs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update parameters here to match parameters in torch.reshape
, with variables mapped to their respective arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question:
the args of helpers.test_frontend_function() should be the expected args of the backend functions, in this case, since torch.reshape only asks for 2 args, input: Tensor, shape: Tuple(int), we would only include these two args for helpers.test_frontend_function(), correct?
use ivy.reshape which is the main alias
question: the args of helpers.test_frontend_function() should be the expected args of the backend functions, in this case, since torch.reshape only asks for 2 args, input: Tensor, shape: Tuple(int), we would only include these two args for helpers.test_frontend_function(), correct?
@juliagsy I've updated per your instructions. I do have two questions if I may:
|
to match backends.torch.reshape's arguments
'ivy/functional/frontends/torch/indexing_slicing_joining_mutating_ops.py:8:1: E305 expected 2 blank lines after class or function definition, found 1'
replace all ' = ' with '='
1. undefined name 'ivy_np' 2. line too long (90 > 88 characters)
…ng_slicing_joining_mutating_ops
1. 31:1: E303 too many blank lines (3) 2. 37:1: E302 expected 2 blank lines, found 1 3. 42:1: W391 blank line at end of file
ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:196:9: E126 continuation line over-indented for hanging indent ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:197:9: E122 continuation line missing indentation or outdented ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:200:9: E122 continuation line missing indentation or outdented ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:201:9: E122 continuation line missing indentation or outdented ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:202:5: E122 continuation line missing indentation or outdented ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:203:5: E131 continuation line unaligned for hanging indent ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:204:5: E131 continuation line unaligned for hanging indent ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:206:5: E122 continuation line missing indentation or outdented ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:207:5: E131 continuation line unaligned for hanging indent ivy_tests/test_ivy/test_frontends/test_tensorflow/test_tf_functions.py:260:1: W391 blank line at end of file
finally caught all the lint :) Also, what's the reason for test-frontend-torch / run-nightly-tests (pull_request) to fail?
|
Hello! To answer your questions:
there are error logs printed if you open up the workflow, the messages can be checked through there! as for the PR, we go by assignee so your new assignee will review your PR soon! thanks for contributing! |
@juliagsy Hi! thanks for the answer. As far as test functions go, I've noticed there are some boilerplates, could you tell me their purpose so I can properly use them for future PRs?
|
oh right, I should've phrase it better, so the args for As we can have array instances or container instances for the inputs, these parameters are used to indicate whether to test the function with: (all are booleans) Some other args: We have a decorator to generate data for these as they are common to all test functions, but don't worry about this as we are currently working on it! I'll share an example from our previous test so that you have a better idea on how they're used! so the parameters up till the we also have documentations for further explanations! hope these will help in clearing your doubts! |
@juliagsy thank you for the detailed reply, very helpful! so for |
They're for testing the backend functions with variables/instances of type ivy.Array or ivy.Container (eg. x.add(y) where x is of type ivy.Container or ivy.Array) It doesn't apply to frontend functions as these functions' behaviours follow their native framework, that's probably the reason it's not mentioned in the docs! Hope this answers your question! |
@juliagsy also, when we write the frontend functions, the arguments should match exactly what the original framework has correct? like so:
and the return should match exactly what the backends has correct?
|
yep, that's right! |
thanks for the clarification :) |
link to issue: #2636