-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Labels
area-System.NumericsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
As noted by @tannergooding:
It's pretty typical for Clamp
APIs to follow a well-specified order for mismatched min/max, as it's far more efficient and is useful for a number of scenarios. -- We end up doing just this for the vector APIs and it correspondingly can bleed into other scenarios, like Tensors
The typical behavior is Min(Max(value, min), max)
which matches what hardware typically does for such instructions, what HLSL and GLSL do, etc. -- Effectively this returns max
if min/max are incorrectly ordered.
Default behavior (min/max are correctly ordered)
value | min | max | result |
---|---|---|---|
1 | 2 | 3 | 2 |
2 | 1 | 3 | 2 |
3 | 1 | 2 | 2 |
Swapped behavior (Min(Max(value, min), max)
)
value | min | max | result |
---|---|---|---|
1 | 3 | 2 | 2 |
2 | 3 | 1 | 1 |
3 | 2 | 1 | 1 |
Swapped behavior (Max(Min(value, max), min)
)
value | min | max | result |
---|---|---|---|
1 | 3 | 2 | 3 |
2 | 3 | 1 | 3 |
3 | 2 | 1 | 2 |
Originally posted by @tannergooding in #118824 (comment)
pentp
Metadata
Metadata
Assignees
Labels
area-System.NumericsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner