-
Notifications
You must be signed in to change notification settings - Fork 53
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
Python bindings and tests for Triu #3637
base: main
Are you sure you want to change the base?
Conversation
6ae6033
to
6d2e7ab
Compare
260141f
to
5f82c65
Compare
6d2e7ab
to
a3ab248
Compare
0b42b74
to
b734bf6
Compare
e134264
to
d66b838
Compare
!test |
This is a C++ API to implement `triu`. The PR (#3637) stacked on top of this used it to create a Python interface. Another way of using this may be to use the components of `triu` such as `iota`, `broadcast`, `le` and `where` from Thunder directly bypassing the need for a C++ implementation. As future work this commit/PR may be removed in favor of a Thunder only implementation.
1794bac
to
0426b46
Compare
!test |
0426b46
to
8339c17
Compare
@jacobhinkle can you take another look? |
@@ -28,10 +28,13 @@ def parse_inputs_fusion_definition(fd: FusionDefinition, opinfo: OpInfo, *args): | |||
) | |||
|
|||
num_symbolic_parameters = len(symbolic_parameter_list) | |||
assert num_symbolic_parameters == len( | |||
assert num_symbolic_parameters >= len( |
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.
@rdspring1 does this change look reasonable?
@@ -63,7 +63,9 @@ def parse_args_fusion_execution(opinfo: OpInfo, *args): | |||
else [ArgumentType.Symbolic] * len(args) | |||
) | |||
|
|||
assert len(symbolic_parameter_list) == len(args) | |||
assert len(symbolic_parameter_list) >= len(args) |
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.
@rdspring1 does this change look okay? I had to make this change we could be generating args of different lengths.
if num_symbolic_parameters > len(args): | ||
symbolic_parameter_list = symbolic_parameter_list[: len(args)] | ||
|
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 doubt this is necessary as zip
will truncate to the length of the shortest argument.
}, | ||
py::arg("input"), | ||
py::arg("diagonal") = 0, | ||
py::return_value_policy::reference); |
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.
Bonus points for adding a pytorch or numpy style docstring. It should go as the last argument in the def
function.
Reference: https://pybind11.readthedocs.io/en/stable/advanced/misc.html#generating-documentation-using-sphinx
This PR exposes the Triu C++ API which was added in the PR (#3631)