Repository navigation
Introduce VBuffer GetValues and GetIndices - #1536
Conversation
TomFinley
left a comment
There was a problem hiding this comment.
This seems quite positive @eerhardt, thank you. Fewer files than I expected too, somehow, but I guess these are the read-only applications. (All of them? That's fine if so, but I expected more somehow. Of course if you're just trying to stage the work in reasonable chunks that's totally fine too.)
| { | ||
| Contracts.AssertValueOrNull(input); | ||
| Contracts.Assert(0 <= min & min <= lim & lim <= Utils.Size(input)); | ||
| return FindIndexSorted(input.AsSpan(), min, lim, value); |
There was a problem hiding this comment.
input.AsSpan() [](start = 35, length = 14)
How heavy is AsSpan operation?
I would rather had two copies of same code for Array and ReadOnlySpan than perf degradation.
There was a problem hiding this comment.
How heavy is AsSpan operation?
It is super lightweight. There is actually in implicit conversion between array and span. It is only necessary here to tell the compiler to call the Span overload instead of the array overload.
| for (int i = 0; i < values.Count; ++i) | ||
| var valuesValues = values.GetValues(); | ||
| var valuesIndices = values.GetIndices(); | ||
| List<KeyValuePair<int, int>> result = new List<KeyValuePair<int, int>>(); |
There was a problem hiding this comment.
List<KeyValuePair<int, int>> [](start = 12, length = 28)
nit: var?
it just stand out:)
also any reason why you prefer return IEnumerable to yield?
There was a problem hiding this comment.
I'll fix it the var here.
also any reason why you prefer return IEnumerable to yield?
It is required because of the Span usage. You can't use a Span in a yield method because you can't hold onto a Span across the yield invocations.
this thing got called once. so maybe it make sense to pass values.GetValues and values.GetIndicies here and call them values and indicies? It just weird to have valuesValues names in code:) Refers to: src/Microsoft.ML.FastTree/FastTree.cs:1045 in 2de8d1f. [](commit_id = 2de8d1f, deletion_comment = False) |
On other thing you have this valuesValues everythere :) so feel free to ignore ^ comment. In reply to: 436738591 [](ancestors = 436738591) Refers to: src/Microsoft.ML.FastTree/FastTree.cs:1045 in 2de8d1f. [](commit_id = 2de8d1f, deletion_comment = False) |
|
Out of curiosity, how is benchmarks looks like? |
Practically identical, and within the margin of error: Without Changes: With Changes: |
Use the new methods in place of Count and Values/Indices in as many readonly situations as possible. Working towards dotnet#608
Update the rest of the BinaryWriter utils to use Span.
5311767 to
86fdf54
Compare
Use the new methods in place of Count and Values/Indices in as many readonly situations as possible.
Working towards #608
See proposed change (4) in #608 (comment)
Eventually,
Count,ValuesandIndiceswill be hidden/private on VBuffer andGetValues()andGetIndices()will be the only way to read these values.