-
Notifications
You must be signed in to change notification settings - Fork 86
Implements aten_index_put if inputs are SymbolicTensor #2606
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2606 +/- ##
==========================================
- Coverage 70.38% 70.38% -0.01%
==========================================
Files 222 222
Lines 26288 26390 +102
Branches 2629 2647 +18
==========================================
+ Hits 18503 18574 +71
- Misses 6865 6886 +21
- Partials 920 930 +10 ☔ View full report in Codecov by Sentry. |
| <https://github.com/pytorch/pytorch/blob/main/torch/onnx/symbolic_opset11.py#L212>`_. | ||
| """ | ||
| if len(indices) > 1 and any( | ||
| isinstance(indice, torch.onnx._internal.exporter._tensors.SymbolicTensor) |
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.
check not isinstance(index, int) instead as we should not reference the private class.
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.
What are the possible types here? Only int and SymbolicTensor? I prefer to keep SymbolicTensor because I know exactly which type the function is supposed to handle.
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.
Only int and SymbolicTensor for the exporter, but could be other ir.Value subclasses as well. As the type is an internal type it is not meant for public use, the current usage is not supported and is brittle.
If preferred you may check for ir.Value instead, but really we just assume a type that has shape and dtype fields
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.
Feel free to suggest. I still prefer to keep this one since this is what shows up in the error message.
| return op.ReduceProd(op.Shape(x, start=i + 1), keepdims=1) | ||
|
|
||
| shape = [1] * (len(x.shape) + 1) | ||
| mfixed = [] |
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.
Prefer clear variable names and avoid abbreviations.
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.
The variable are used just after. It is short to make the code shorter and esier to read.
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.
Any abbreviation adds cognitive load and is not preferred. All names should be thoughtfully created to be precise. Creating variables used right after is a plus but I don’t feel warranting the use of ambiguous names.
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.
I let you choose the name.
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.
As commented:
- avoid referencing internal members
- follow existing coding style for choosing names for consistency and readability
| """ | ||
| if ( | ||
| len(indices) > 1 | ||
| and any( |
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.
Is there a pointer to the real use-cases that show up? I thought each index in indices is supposed to be a 1D tensor? What are the ways in which SymbolicTensors are created?
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.
Is a SymbolicTensor a 1-element tensor version of a SymbolicInt?
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.
SymbolicTensor is just ir.Value with magic methods defined to support python operators.
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.
Here the symbolic tensors are created from the symints.
No description provided.