Skip to content

Commit bd00c1e

Browse files
artidoroTomFinley
authored andcommitted
Microsoft.ML.Transforms assembly lockdown (#2648)
* Internalization and some commenting for transforms assembly. * Internalized CheckInputColumn method.
1 parent bd64b88 commit bd00c1e

29 files changed

+107
-50
lines changed

src/Microsoft.ML.Data/Transforms/Hashing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private static VersionInfo GetVersionInfo()
136136
private readonly VBuffer<ReadOnlyMemory<char>>[] _keyValues;
137137
private readonly VectorType[] _kvTypes;
138138

139-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
139+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
140140
{
141141
var type = inputSchema[srcCol].Type;
142142
if (!HashingEstimator.IsColumnTypeValid(type))

src/Microsoft.ML.Data/Transforms/KeyToVector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private string TestIsKey(DataViewType type)
112112
return "key type of known cardinality";
113113
}
114114

115-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
115+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
116116
{
117117
var type = inputSchema[srcCol].Type;
118118
string reason = TestIsKey(type);

src/Microsoft.ML.Data/Transforms/Normalizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
561561
}
562562
}
563563

564-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
564+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
565565
{
566566
const string expectedType = "scalar or known-size vector of R4";
567567

src/Microsoft.ML.Data/Transforms/OneToOneTransformerBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ private void CheckInput(DataViewSchema inputSchema, int col, out int srcCol)
7878
CheckInputColumn(inputSchema, col, srcCol);
7979
}
8080

81-
protected virtual void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
81+
[BestFriend]
82+
private protected virtual void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
8283
{
8384
// By default, there are no extra checks.
8485
}

src/Microsoft.ML.HalLearners/VectorWhitening.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ internal static IRowMapper Create(IHostEnvironment env, ModelLoadContext ctx, Da
209209
private static (string outputColumnName, string inputColumnName)[] GetColumnPairs(VectorWhiteningEstimator.ColumnInfo[] columns)
210210
=> columns.Select(c => (c.Name, c.InputColumnName ?? c.Name)).ToArray();
211211

212-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
212+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
213213
{
214214
var inType = inputSchema[srcCol].Type;
215215
var reason = TestColumn(inType);

src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
164164

165165
private protected override IRowMapper MakeRowMapper(DataViewSchema schema) => new Mapper(this, schema);
166166

167-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
167+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
168168
{
169169
if (!(inputSchema[srcCol].Type is ImageType))
170170
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", ColumnPairs[col].inputColumnName, "image", inputSchema[srcCol].Type.ToString());

src/Microsoft.ML.ImageAnalytics/ImageLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static IDataTransform Create(IHostEnvironment env, ModelLoadContext ctx,
131131
private static IRowMapper Create(IHostEnvironment env, ModelLoadContext ctx, DataViewSchema inputSchema)
132132
=> Create(env, ctx).MakeRowMapper(inputSchema);
133133

134-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
134+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
135135
{
136136
if (!(inputSchema[srcCol].Type is TextDataViewType))
137137
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", ColumnPairs[col].inputColumnName, TextDataViewType.Instance.ToString(), inputSchema[srcCol].Type.ToString());

src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
272272

273273
private protected override IRowMapper MakeRowMapper(DataViewSchema schema) => new Mapper(this, schema);
274274

275-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
275+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
276276
{
277277
var inputColName = _columns[col].InputColumnName;
278278
var imageType = inputSchema[srcCol].Type as ImageType;

src/Microsoft.ML.ImageAnalytics/ImageResizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
265265

266266
private protected override IRowMapper MakeRowMapper(DataViewSchema schema) => new Mapper(this, schema);
267267

268-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
268+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
269269
{
270270
if (!(inputSchema[srcCol].Type is ImageType))
271271
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", _columns[col].InputColumnName, "image", inputSchema[srcCol].Type.ToString());

src/Microsoft.ML.PCA/PcaTransformer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private float[][] PostProcess(float[][] y, float[] sigma, float[] z, int d, int
499499

500500
private protected override IRowMapper MakeRowMapper(DataViewSchema schema) => new Mapper(this, schema);
501501

502-
protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
502+
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
503503
{
504504
ValidatePcaInput(Host, inputSchema[srcCol].Name, inputSchema[srcCol].Type);
505505
}

0 commit comments

Comments
 (0)