Skip to content

Replace DvInt* with .NET standard data types. WIP #683

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

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9ba4dab
trigger build.
GalOshri Aug 7, 2018
baf0696
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 14, 2018
f7a0fff
Datakinds, ColumnTypes and NAHandle.
codemzs Aug 14, 2018
1fdfe0d
Change metadata for categorical indices from DvInt4 to Int32.
codemzs Aug 15, 2018
734540f
Conversions class.
codemzs Aug 15, 2018
10d753c
peak, poke, codecs, transforms, evaluators.
codemzs Aug 16, 2018
46299b8
test.
codemzs Aug 16, 2018
a99831b
undo DvBool.
codemzs Aug 16, 2018
a0ceabb
undo DvBool.
codemzs Aug 16, 2018
f30dd7e
Replace DvInt* with .NET standard types and remove missing value supp…
codemzs Aug 16, 2018
a6e5c75
PR feedback.
codemzs Aug 16, 2018
c4bae95
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 16, 2018
9aea10b
clean up.
codemzs Aug 16, 2018
db2da0b
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 17, 2018
5d14c0a
PR feedback.
codemzs Aug 21, 2018
9051ef9
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 21, 2018
789182a
merge master and fix tests.
codemzs Aug 21, 2018
4e70eb4
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 21, 2018
ef54c60
merge master and fix tests.
codemzs Aug 21, 2018
83dec91
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 23, 2018
b3ba06d
PR feedback.
codemzs Aug 23, 2018
fb9f792
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 23, 2018
25d1a52
PR feedback.
codemzs Aug 23, 2018
1853471
PR feedback.
codemzs Aug 23, 2018
66fa9be
PR feedback.
codemzs Aug 23, 2018
f17b7b0
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 24, 2018
0c8fb8c
Tests.
codemzs Aug 26, 2018
f16b0a9
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 26, 2018
9c128a3
cleanup.
codemzs Aug 26, 2018
9c4eebf
cleanup.
codemzs Aug 26, 2018
d7ba332
Add IDV test for backward compatiblity with DvTypes.
codemzs Aug 27, 2018
63e45e7
baseline and idv file.
codemzs Aug 27, 2018
39f150b
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 27, 2018
11be480
Merge branch 'idvtest' of https://github.com/codemzs/machinelearning …
codemzs Aug 27, 2018
681b3ef
PR feedback.
codemzs Aug 27, 2018
1a38dfe
Merge branch 'idvtest' of https://github.com/codemzs/machinelearning …
codemzs Aug 27, 2018
7580513
disable test for Linux.
codemzs Aug 28, 2018
3c5ce8e
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 28, 2018
8f8e544
PR feedback.
codemzs Aug 28, 2018
3fb1cc2
add more tests.
codemzs Aug 28, 2018
c844b4e
PR feedback.
codemzs Aug 28, 2018
53b4e57
add test for parquet loader.
codemzs Aug 28, 2018
f1d1da6
Merge branch 'parquettest' of https://github.com/codemzs/machinelearn…
codemzs Aug 28, 2018
f05e2f1
Update parquet tests.
codemzs Aug 28, 2018
33b7150
PR feedback.
codemzs Aug 28, 2018
d028702
fix build.
codemzs Aug 28, 2018
9a4f192
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 29, 2018
a7cd3d8
PR feedback.
codemzs Aug 30, 2018
40c01fc
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 30, 2018
ad37fb5
cleanup.
codemzs Aug 30, 2018
b9edc92
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Aug 31, 2018
078cd8c
resolve merge conflict.
codemzs Aug 31, 2018
be3d177
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Sep 3, 2018
cd7de9f
PR feedback.
codemzs Sep 4, 2018
7e80e50
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
codemzs Sep 7, 2018
9d4f4d6
merge master.
codemzs Sep 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Microsoft.ML.Api/ApiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ private static OpCode GetAssignmentOpCode(Type t)
{
// REVIEW: This should be a Dictionary<Type, OpCode> based solution.
// DvTypes, strings, arrays, all nullable types, VBuffers and UInt128.
if (t == typeof(DvInt8) || t == typeof(DvInt4) || t == typeof(DvInt2) || t == typeof(DvInt1) ||
t == typeof(DvBool) || t == typeof(DvText) || t == typeof(string) || t.IsArray ||
if (t == typeof(DvText) || t == typeof(DvBool) || t == typeof(string) || t.IsArray ||
(t.IsGenericType && t.GetGenericTypeDefinition() == typeof(VBuffer<>)) ||
(t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) ||
t == typeof(DvDateTime) || t == typeof(DvDateTimeZone) || t == typeof(DvTimeSpan) || t == typeof(UInt128))
Expand Down
88 changes: 0 additions & 88 deletions src/Microsoft.ML.Api/DataViewConstructionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,46 +131,6 @@ private Delegate CreateGetter(int index)
Ch.Assert(colType.ItemType.IsText);
return CreateConvertingArrayGetterDelegate<String, DvText>(index, x => x == null ? DvText.NA : new DvText(x));
}
else if (outputType.GetElementType() == typeof(int))
{
Ch.Assert(colType.ItemType == NumberType.I4);
return CreateConvertingArrayGetterDelegate<int, DvInt4>(index, x => x);
}
else if (outputType.GetElementType() == typeof(int?))
{
Ch.Assert(colType.ItemType == NumberType.I4);
return CreateConvertingArrayGetterDelegate<int?, DvInt4>(index, x => x ?? DvInt4.NA);
}
else if (outputType.GetElementType() == typeof(long))
{
Ch.Assert(colType.ItemType == NumberType.I8);
return CreateConvertingArrayGetterDelegate<long, DvInt8>(index, x => x);
}
else if (outputType.GetElementType() == typeof(long?))
{
Ch.Assert(colType.ItemType == NumberType.I8);
return CreateConvertingArrayGetterDelegate<long?, DvInt8>(index, x => x ?? DvInt8.NA);
}
else if (outputType.GetElementType() == typeof(short))
{
Ch.Assert(colType.ItemType == NumberType.I2);
return CreateConvertingArrayGetterDelegate<short, DvInt2>(index, x => x);
}
else if (outputType.GetElementType() == typeof(short?))
{
Ch.Assert(colType.ItemType == NumberType.I2);
return CreateConvertingArrayGetterDelegate<short?, DvInt2>(index, x => x ?? DvInt2.NA);
}
else if (outputType.GetElementType() == typeof(sbyte))
{
Ch.Assert(colType.ItemType == NumberType.I1);
return CreateConvertingArrayGetterDelegate<sbyte, DvInt1>(index, x => x);
}
else if (outputType.GetElementType() == typeof(sbyte?))
{
Ch.Assert(colType.ItemType == NumberType.I1);
return CreateConvertingArrayGetterDelegate<sbyte?, DvInt1>(index, x => x ?? DvInt1.NA);
}
else if (outputType.GetElementType() == typeof(bool))
{
Ch.Assert(colType.ItemType.IsBool);
Expand Down Expand Up @@ -220,54 +180,6 @@ private Delegate CreateGetter(int index)
Ch.Assert(colType.IsBool);
return CreateConvertingGetterDelegate<bool?, DvBool>(index, x => x ?? DvBool.NA);
}
else if (outputType == typeof(int))
{
// int -> DvInt4
Ch.Assert(colType == NumberType.I4);
return CreateConvertingGetterDelegate<int, DvInt4>(index, x => x);
}
else if (outputType == typeof(int?))
{
// int? -> DvInt4
Ch.Assert(colType == NumberType.I4);
return CreateConvertingGetterDelegate<int?, DvInt4>(index, x => x ?? DvInt4.NA);
}
else if (outputType == typeof(short))
{
// short -> DvInt2
Ch.Assert(colType == NumberType.I2);
return CreateConvertingGetterDelegate<short, DvInt2>(index, x => x);
}
else if (outputType == typeof(short?))
{
// short? -> DvInt2
Ch.Assert(colType == NumberType.I2);
return CreateConvertingGetterDelegate<short?, DvInt2>(index, x => x ?? DvInt2.NA);
}
else if (outputType == typeof(long))
{
// long -> DvInt8
Ch.Assert(colType == NumberType.I8);
return CreateConvertingGetterDelegate<long, DvInt8>(index, x => x);
}
else if (outputType == typeof(long?))
{
// long? -> DvInt8
Ch.Assert(colType == NumberType.I8);
return CreateConvertingGetterDelegate<long?, DvInt8>(index, x => x ?? DvInt8.NA);
}
else if (outputType == typeof(sbyte))
{
// sbyte -> DvInt1
Ch.Assert(colType == NumberType.I1);
return CreateConvertingGetterDelegate<sbyte, DvInt1>(index, x => x);
}
else if (outputType == typeof(sbyte?))
{
// sbyte? -> DvInt1
Ch.Assert(colType == NumberType.I1);
return CreateConvertingGetterDelegate<sbyte?, DvInt1>(index, x => x ?? DvInt1.NA);
}
// T -> T
if (outputType.IsGenericType && outputType.GetGenericTypeDefinition() == typeof(Nullable<>))
Ch.Assert(colType.RawType == Nullable.GetUnderlyingType(outputType));
Expand Down
89 changes: 1 addition & 88 deletions src/Microsoft.ML.Api/TypedCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,46 +292,6 @@ private Action<TRow> GenerateSetter(IRow input, int index, InternalSchemaDefinit
Ch.Assert(colType.ItemType.IsBool);
return CreateConvertingVBufferSetter<DvBool, bool?>(input, index, poke, peek, x => (bool?)x);
}
else if (fieldType.GetElementType() == typeof(int))
{
Ch.Assert(colType.ItemType == NumberType.I4);
return CreateConvertingVBufferSetter<DvInt4, int>(input, index, poke, peek, x => (int)x);
}
else if (fieldType.GetElementType() == typeof(int?))
{
Ch.Assert(colType.ItemType == NumberType.I4);
return CreateConvertingVBufferSetter<DvInt4, int?>(input, index, poke, peek, x => (int?)x);
}
else if (fieldType.GetElementType() == typeof(short))
{
Ch.Assert(colType.ItemType == NumberType.I2);
return CreateConvertingVBufferSetter<DvInt2, short>(input, index, poke, peek, x => (short)x);
}
else if (fieldType.GetElementType() == typeof(short?))
{
Ch.Assert(colType.ItemType == NumberType.I2);
return CreateConvertingVBufferSetter<DvInt2, short?>(input, index, poke, peek, x => (short?)x);
}
else if (fieldType.GetElementType() == typeof(long))
{
Ch.Assert(colType.ItemType == NumberType.I8);
return CreateConvertingVBufferSetter<DvInt8, long>(input, index, poke, peek, x => (long)x);
}
else if (fieldType.GetElementType() == typeof(long?))
{
Ch.Assert(colType.ItemType == NumberType.I8);
return CreateConvertingVBufferSetter<DvInt8, long?>(input, index, poke, peek, x => (long?)x);
}
else if (fieldType.GetElementType() == typeof(sbyte))
{
Ch.Assert(colType.ItemType == NumberType.I1);
return CreateConvertingVBufferSetter<DvInt1, sbyte>(input, index, poke, peek, x => (sbyte)x);
}
else if (fieldType.GetElementType() == typeof(sbyte?))
{
Ch.Assert(colType.ItemType == NumberType.I1);
return CreateConvertingVBufferSetter<DvInt1, sbyte?>(input, index, poke, peek, x => (sbyte?)x);
}

// VBuffer<T> -> T[]
if (fieldType.GetElementType().IsGenericType && fieldType.GetElementType().GetGenericTypeDefinition() == typeof(Nullable<>))
Expand Down Expand Up @@ -372,54 +332,7 @@ private Action<TRow> GenerateSetter(IRow input, int index, InternalSchemaDefinit
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvBool, bool?>(input, index, poke, x => (bool?)x);
}
else if (fieldType == typeof(int))
{
Ch.Assert(colType == NumberType.I4);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt4, int>(input, index, poke, x => (int)x);
}
else if (fieldType == typeof(int?))
{
Ch.Assert(colType == NumberType.I4);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt4, int?>(input, index, poke, x => (int?)x);
}
else if (fieldType == typeof(short))
{
Ch.Assert(colType == NumberType.I2);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt2, short>(input, index, poke, x => (short)x);
}
else if (fieldType == typeof(short?))
{
Ch.Assert(colType == NumberType.I2);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt2, short?>(input, index, poke, x => (short?)x);
}
else if (fieldType == typeof(long))
{
Ch.Assert(colType == NumberType.I8);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt8, long>(input, index, poke, x => (long)x);
}
else if (fieldType == typeof(long?))
{
Ch.Assert(colType == NumberType.I8);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt8, long?>(input, index, poke, x => (long?)x);
}
else if (fieldType == typeof(sbyte))
{
Ch.Assert(colType == NumberType.I1);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt1, sbyte>(input, index, poke, x => (sbyte)x);
}
else if (fieldType == typeof(sbyte?))
{
Ch.Assert(colType == NumberType.I1);
Ch.Assert(peek == null);
return CreateConvertingActionSetter<DvInt1, sbyte?>(input, index, poke, x => (sbyte?)x);
}

// T -> T
if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Nullable<>))
Ch.Assert(colType.RawType == Nullable.GetUnderlyingType(fieldType));
Expand Down
14 changes: 7 additions & 7 deletions src/Microsoft.ML.Core/CommandLine/CmdParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,23 +517,23 @@ public static int GetConsoleWindowWidth()

private struct Coord
{
internal Int16 X;
internal Int16 Y;
internal short X;
internal short Y;
}

private struct SmallRect
{
internal Int16 Left;
internal Int16 Top;
internal Int16 Right;
internal Int16 Bottom;
internal short Left;
internal short Top;
internal short Right;
internal short Bottom;
}

private struct ConsoleScreenBufferInfo
{
internal Coord DwSize;
internal Coord DwCursorPosition;
internal Int16 WAttributes;
internal short WAttributes;
internal SmallRect SrWindow;
internal Coord DwMaximumWindowSize;
}
Expand Down
32 changes: 16 additions & 16 deletions src/Microsoft.ML.Core/Data/DataKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public enum DataKind : byte
public static class DataKindExtensions
{
public const DataKind KindMin = DataKind.I1;
public const DataKind KindLim = DataKind.UG + 1;
public const DataKind KindLim = DataKind.U16 + 1;
public const int KindCount = KindLim - KindMin;

/// <summary>
Expand Down Expand Up @@ -141,19 +141,19 @@ public static Type ToType(this DataKind kind)
switch (kind)
{
case DataKind.I1:
return typeof(DvInt1);
return typeof(sbyte);
case DataKind.U1:
return typeof(byte);
case DataKind.I2:
return typeof(DvInt2);
return typeof(short);
case DataKind.U2:
return typeof(ushort);
case DataKind.I4:
return typeof(DvInt4);
return typeof(int);
case DataKind.U4:
return typeof(uint);
case DataKind.I8:
return typeof(DvInt8);
return typeof(long);
case DataKind.U8:
return typeof(ulong);
case DataKind.R4:
Expand Down Expand Up @@ -185,29 +185,29 @@ public static bool TryGetDataKind(this Type type, out DataKind kind)
Contracts.CheckValueOrNull(type);

// REVIEW: Make this more efficient. Should we have a global dictionary?
if (type == typeof(DvInt1) || type == typeof(sbyte) || type == typeof(sbyte?))
if (type == typeof(sbyte))
kind = DataKind.I1;
else if (type == typeof(byte) || type == typeof(byte?))
else if (type == typeof(byte))
kind = DataKind.U1;
else if (type == typeof(DvInt2)|| type== typeof(short) || type == typeof(short?))
else if (type == typeof(short))
kind = DataKind.I2;
else if (type == typeof(ushort)|| type == typeof(ushort?))
else if (type == typeof(ushort))
kind = DataKind.U2;
else if (type == typeof(DvInt4) || type == typeof(int)|| type == typeof(int?))
else if (type == typeof(int))
kind = DataKind.I4;
else if (type == typeof(uint)|| type == typeof(uint?))
else if (type == typeof(uint))
kind = DataKind.U4;
else if (type == typeof(DvInt8) || type==typeof(long)|| type == typeof(long?))
else if (type == typeof(long))
kind = DataKind.I8;
else if (type == typeof(ulong)|| type == typeof(ulong?))
else if (type == typeof(ulong))
kind = DataKind.U8;
else if (type == typeof(Single)|| type == typeof(Single?))
else if (type == typeof(Single))
kind = DataKind.R4;
else if (type == typeof(Double)|| type == typeof(Double?))
else if (type == typeof(Double))
kind = DataKind.R8;
else if (type == typeof(DvText))
kind = DataKind.TX;
else if (type == typeof(DvBool) || type == typeof(bool) || type == typeof(bool?))
else if (type == typeof(DvBool) || type == typeof(bool))
kind = DataKind.BL;
else if (type == typeof(DvTimeSpan))
kind = DataKind.TS;
Expand Down
Loading