-
Notifications
You must be signed in to change notification settings - Fork 612
[linalg] : Use (-)realmax instead of (-)inf to avoid usage of non-finites. #4363
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?
Conversation
| APFloat::getLargest( | ||
| cast<mlir::FloatType>(inElementType).getFloatSemantics(), |
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.
It'll be good to add testpoints for torch.aten.min.dim and torch.aten.max.dim test to basic.mlir to lock this down.
Also, does TorchToTosa not support this and pooling with padding?
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.
By testpoints do you mean e2e tests or lit tests?
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'm not sure how much this practically matters, but min(x, inf) is only the same as min(x, realmax) if x is finite, so this change will possibly result in incorrect results when the input tensors have non-finites. E.g., if you had an e2e test for torch.min and the input was a splat torch.inf tensor, then pytorch would return inf and not realmax.
| APFloat::getLargest( | ||
| cast<mlir::FloatType>(inElementType).getFloatSemantics(), |
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.
By testpoints do you mean e2e tests or lit tests?
Great point, I hadn't thought of that. It appears that without this change, if I pass a tensor of all It seems wrong to me to knowingly introduce this discrepancy with torch even though the scenario doesn't make sense in practice. One alternative is to introduce a flag, such as |
This change replaces usage of non-finite value
infwith finite valuerealmaxfor init value of various max/min operations -- no change in semantics of the ops.