-
Notifications
You must be signed in to change notification settings - Fork 92
add std_mean
op
#1971
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
base: main
Are you sure you want to change the base?
add std_mean
op
#1971
Conversation
@beverlylytle, would you like to review this PR? |
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.
This looks good, thank you! I was looking through PyTorch's issues for std_mean
and I leave two thoughts for your consideration:
- Did you happen to check
float('inf')
values?torch.std_mean
returnsNaN
as mean of aninf
array. pytorch/pytorch#138570 - I don't think there's something to be done here, but I thought it was interesting: torch.std_mean slower than separate torch.mean and torch.std calls on CPU pytorch/pytorch#122191
sample_input_generator=std_sample_generator, | ||
error_input_generator=std_error_generator, | ||
torch_reference=torch.std_mean, | ||
dtypes=(datatypes.floating,), |
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.
There are checks in the meta for complex types, but they are omitted from testing. I know there are other issues with testing complex types, but were they left out here for a reason?
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.
Does this need to be a prim? I think we can just have a decomposition in torch/__init__.py
which calls ltorch.mean
and ltorch.std
. Fusion executor like nvFuser would generate a good kernel. This way, we won't need to add a prim and grad rule for the same.
Wdyt @khushi-411 @beverlylytle?
@kshitij12345 you make a good point, but |
Good point. That makes sense to me, thanks! |
For But I could be mistaken. |
I am inclined against being so prescriptive without a hard reason. While it's possible that executors may want to provide their own implementations of |
Sounds good; executors can also consume the torch operation directly if they have custom std+mean logic. |
As per the title.