Skip to content

Commit cb9effc

Browse files
authored
Introduce VBufferEditor and hide VBuffer.Count (#1580)
* Implement VBuffer master plan WIP #1 * Getting everything to build and tests passing * Keep moving to the master plan of VBuffer. * Remove the rest of the VBuffer.Count usages in ML.Data * Remove the rest of the VBuffer.Count usages and make VBuffer.Count private. * Fix two failing tests. * Fix FastTreeBinaryClassificationCategoricalSplitTest by remembering the underlying arrays in the column buffer in Transposer. Also enable a Transposer test, since it passes.
1 parent 8a45f37 commit cb9effc

File tree

90 files changed

+1811
-1717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1811
-1717
lines changed

src/Microsoft.ML.Core/Data/MetadataUtils.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ public static void GetSlotNames(RoleMappedSchema schema, RoleMappedSchema.Column
318318

319319
IReadOnlyList<ColumnInfo> list;
320320
if ((list = schema?.GetColumns(role)) == null || list.Count != 1 || !schema.Schema.HasSlotNames(list[0].Index, vectorSize))
321-
slotNames = new VBuffer<ReadOnlyMemory<char>>(vectorSize, 0, slotNames.Values, slotNames.Indices);
321+
{
322+
VBufferUtils.Resize(ref slotNames, vectorSize, 0);
323+
}
322324
else
323325
schema.Schema.GetMetadata(Kinds.SlotNames, list[0].Index, ref slotNames);
324326
}
@@ -447,21 +449,22 @@ public static bool TryGetCategoricalFeatureIndices(Schema schema, int colIndex,
447449
{
448450
int previousEndIndex = -1;
449451
isValid = true;
450-
for (int i = 0; i < catIndices.Values.Length; i += 2)
452+
var catIndicesValues = catIndices.GetValues();
453+
for (int i = 0; i < catIndicesValues.Length; i += 2)
451454
{
452-
if (catIndices.Values[i] > catIndices.Values[i + 1] ||
453-
catIndices.Values[i] <= previousEndIndex ||
454-
catIndices.Values[i] >= columnSlotsCount ||
455-
catIndices.Values[i + 1] >= columnSlotsCount)
455+
if (catIndicesValues[i] > catIndicesValues[i + 1] ||
456+
catIndicesValues[i] <= previousEndIndex ||
457+
catIndicesValues[i] >= columnSlotsCount ||
458+
catIndicesValues[i + 1] >= columnSlotsCount)
456459
{
457460
isValid = false;
458461
break;
459462
}
460463

461-
previousEndIndex = catIndices.Values[i + 1];
464+
previousEndIndex = catIndicesValues[i + 1];
462465
}
463466
if (isValid)
464-
categoricalFeatures = catIndices.Values.Select(val => val).ToArray();
467+
categoricalFeatures = catIndicesValues.ToArray();
465468
}
466469
}
467470

0 commit comments

Comments
 (0)