Skip to content

Commit

Permalink
Implement VBuffer master plan WIP #1
Browse files Browse the repository at this point in the history
  • Loading branch information
eerhardt committed Nov 8, 2018
1 parent f222025 commit 3577441
Show file tree
Hide file tree
Showing 25 changed files with 816 additions and 681 deletions.
20 changes: 12 additions & 8 deletions src/Microsoft.ML.Core/Data/MetadataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ public static void GetSlotNames(RoleMappedSchema schema, RoleMappedSchema.Column

IReadOnlyList<ColumnInfo> list;
if ((list = schema?.GetColumns(role)) == null || list.Count != 1 || !schema.Schema.HasSlotNames(list[0].Index, vectorSize))
slotNames = new VBuffer<ReadOnlyMemory<char>>(vectorSize, 0, slotNames.Values, slotNames.Indices);
{
VBufferMutationContext.Create(ref slotNames, vectorSize, 0)
.Complete(ref slotNames);
}
else
schema.Schema.GetMetadata(Kinds.SlotNames, list[0].Index, ref slotNames);
}
Expand Down Expand Up @@ -447,21 +450,22 @@ public static bool TryGetCategoricalFeatureIndices(Schema schema, int colIndex,
{
int previousEndIndex = -1;
isValid = true;
for (int i = 0; i < catIndices.Values.Length; i += 2)
var catIndicesValues = catIndices.GetValues();
for (int i = 0; i < catIndicesValues.Length; i += 2)
{
if (catIndices.Values[i] > catIndices.Values[i + 1] ||
catIndices.Values[i] <= previousEndIndex ||
catIndices.Values[i] >= columnSlotsCount ||
catIndices.Values[i + 1] >= columnSlotsCount)
if (catIndicesValues[i] > catIndicesValues[i + 1] ||
catIndicesValues[i] <= previousEndIndex ||
catIndicesValues[i] >= columnSlotsCount ||
catIndicesValues[i + 1] >= columnSlotsCount)
{
isValid = false;
break;
}

previousEndIndex = catIndices.Values[i + 1];
previousEndIndex = catIndicesValues[i + 1];
}
if (isValid)
categoricalFeatures = catIndices.Values.Select(val => val).ToArray();
categoricalFeatures = catIndicesValues.ToArray();
}
}

Expand Down
Loading

0 comments on commit 3577441

Please sign in to comment.