-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some behavioral / perf fixes for Embedding<T> (#567)
### Motivation and Context Clean up some `Embedding<T>` behaviors / perf issues. ### Description - IsSupported was more expensive than it needs to be: if it's changed to just compare the types directly rather than searching a list, the JIT can turn the entire operation into a JIT-time constant. - The explicit cast to `ReadOnlySpan<T>` was cloning the array. It doesn't need to do that. - `default(Embedding<T>)` results in a struct that fails on a bunch of operations with NullReferenceExceptions if you try to use it. We've learned from experience with `ImmutableArray<T>` this is suboptimal. I've made it functional and behave equivalent to Empty... in fact, Empty is now just `default`.
- Loading branch information
1 parent
a0aa0c5
commit 15dc234
Showing
5 changed files
with
106 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters