-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use TensorPrimitives.ElementWiseSelect instead of ConditionalSelect in more places #97282
Conversation
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsAlso special-case nint/nuint in ElementWiseSelect.
|
64680ca
to
3d35414
Compare
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs
Outdated
Show resolved
Hide resolved
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs
Outdated
Show resolved
Hide resolved
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs
Outdated
Show resolved
Hide resolved
@BrzVlad, mono interpreter legs are crashing:
Do you want to take a look? |
For me the issue is not interp only, it happens also on mono jit. Not sure how the tests passed on this PR. It seems lately that I'm wondering how CoreCLR handles cases like:
Where |
Yes, it's being used in many more places now, especially with intrinsics/vectorization, special-casing for different types, using generic specialization to drive different behaviors based on call site, etc.
cc: @EgorBo, @tannergooding |
Yes, RyuJIT eliminates simple branches like that before it starts inlining, e.g. if (Sse2.IsSupported)
{
call();
} it never tries to import/inline that call basically |
There is already a PR up for Mono that is attempting to address some of the memory usage issues it is seeing: #97096 |
Also it's worth noting here that RyuJIT specializes all value types, so it can fold type checks on those too. |
I believe that one doesn't fix the root cause - it still inlines stuff in all blocks, it just removes them before it starts emitting LLVM IR. |
ca7eb70
to
fba4be9
Compare
To avoid unnecessarily exacerbating the problem, I trimmed this back to just the condensing of the ElementWiseSelect if checks. But we will need to address the underlying mono issues around this. This kind of code is only going to increase. |
Also special-case nint/nuint in ElementWiseSelect.