Skip to content

Commit 179f7dc

Browse files
authored
Add TargetType to Type_convert (#6785)
* Add target Type in convert type * Add custom type "DataKind" * clean * Add DataKind name space * clean test
1 parent c28d5af commit 179f7dc

File tree

8 files changed

+39
-6
lines changed

8 files changed

+39
-6
lines changed

src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@
4646
"BertArchitecture.Roberta"
4747
]
4848
},
49+
"dataKind": {
50+
"type": "string",
51+
"enum": [
52+
"DataKind.Int16",
53+
"DataKind.SByte",
54+
"DataKind.Byte",
55+
"DataKind.UInt16",
56+
"DataKind.Int32",
57+
"DataKind.UInt32",
58+
"DataKind.Int64",
59+
"DataKind.UInt64",
60+
"DataKind.Single",
61+
"DataKind.Double",
62+
"DataKind.String",
63+
"DataKind.Boolean",
64+
"DataKind.TimeSpan",
65+
"DataKind.DateTime",
66+
"DataKind.DateTimeOffset"
67+
]
68+
},
4969
"bertArchitectureArray": {
5070
"type": "array",
5171
"items": {
@@ -217,7 +237,8 @@
217237
"TrainingAnswerColumnName",
218238
"AnswerIndexStartColumnName",
219239
"predictedAnswerColumnName",
220-
"TopKAnswers"
240+
"TopKAnswers",
241+
"TargetType"
221242
]
222243
},
223244
"option_type": {
@@ -235,7 +256,8 @@
235256
"anchor",
236257
"dnnModelFactory",
237258
"bertArchitecture",
238-
"imageClassificationArchType"
259+
"imageClassificationArchType",
260+
"dataKind"
239261
]
240262
}
241263
},

src/Microsoft.ML.AutoML/CodeGen/type_converter_search_space.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
{
1010
"name": "InputColumnNames",
1111
"type": "strings"
12+
},
13+
{
14+
"name": "TargetType",
15+
"type": "dataKind",
16+
"default": "DataKind.Single"
1217
}
1318
]
1419
}

src/Microsoft.ML.AutoML/SweepableEstimator/Estimators/TypeConvert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal partial class ConvertType
99
public override IEstimator<ITransformer> BuildFromOption(MLContext context, ConvertTypeOption param)
1010
{
1111
var inputOutputPairs = AutoMlUtils.CreateInputOutputColumnPairsFromStrings(param.InputColumnNames, param.OutputColumnNames);
12-
return context.Transforms.Conversion.ConvertType(inputOutputPairs);
12+
return context.Transforms.Conversion.ConvertType(inputOutputPairs, param.TargetType);
1313
}
1414
}
1515
}

test/Microsoft.ML.AutoML.Tests/ApprovalTests/AutoFeaturizerTests.AutoFeaturizer_creditapproval_test.approved.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
],
2222
"InputColumnNames": [
2323
"BooleanFeatures"
24-
]
24+
],
25+
"TargetType": "Single"
2526
}
2627
},
2728
"e2": {

test/Microsoft.ML.AutoML.Tests/ApprovalTests/AutoFeaturizerTests.AutoFeaturizer_newspaperchurn_test.approved.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
],
2222
"InputColumnNames": [
2323
"dummy for Children"
24-
]
24+
],
25+
"TargetType": "Single"
2526
}
2627
},
2728
"e2": {

tools-local/Microsoft.ML.AutoML.SourceGenerator/SearchSpaceGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public void Execute(GeneratorExecutionContext context)
5656
"dnnModelFactory" => "string",
5757
"bertArchitecture" => "BertArchitecture",
5858
"imageClassificationArchType" => "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture",
59+
"dataKind" => "Microsoft.ML.Data.DataKind",
5960
_ => throw new ArgumentException("unknown type"),
6061
};
6162

@@ -74,6 +75,7 @@ public void Execute(GeneratorExecutionContext context)
7475
(_, "ColorsOrder") => defaultToken.GetValue<string>(),
7576
(_, "BertArchitecture") => defaultToken.GetValue<string>(),
7677
(_, "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture") => defaultToken.GetValue<string>(),
78+
(_, "Microsoft.ML.Data.DataKind") => defaultToken.GetValue<string>(),
7779
(_, _) => throw new ArgumentException("unknown"),
7880
};
7981

tools-local/Microsoft.ML.AutoML.SourceGenerator/Template/SearchSpace.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public virtual string TransformText()
3434
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
3535
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
3636
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
37+
using DataKind = Microsoft.ML.Data.DataKind;
3738
#nullable enable
3839
3940
namespace ");
@@ -92,7 +93,7 @@ internal class SearchSpaceBase
9293
/// <summary>
9394
/// The string builder that generation-time code is using to assemble generated output
9495
/// </summary>
95-
protected System.Text.StringBuilder GenerationEnvironment
96+
public System.Text.StringBuilder GenerationEnvironment
9697
{
9798
get
9899
{

tools-local/Microsoft.ML.AutoML.SourceGenerator/Template/SearchSpace.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using ResizingKind = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Resizi
1212
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
1313
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
1414
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
15+
using DataKind = Microsoft.ML.Data.DataKind;
1516
#nullable enable
1617

1718
namespace <#=NameSpace#>

0 commit comments

Comments
 (0)