Skip to content

Commit 17f795c

Browse files
SDL fixes. (dotnet#5977)
1 parent 7f013a2 commit 17f795c

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

src/Directory.Build.props

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<WarningsNotAsErrors>$(WarningsNotAsErrors);1591</WarningsNotAsErrors>
1313

1414
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\Source.ruleset</CodeAnalysisRuleSet>
15-
15+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
16+
1617
<NativeAssetsBuiltPath>$(BaseOutputPath)$(TargetArchitecture).$(Configuration)</NativeAssetsBuiltPath>
1718

1819
<PackageRid Condition="'$(OS)' == 'Windows_NT'">win</PackageRid>
@@ -33,17 +34,14 @@
3334
<RunMatchingRefApiCompat>false</RunMatchingRefApiCompat>
3435
<ApiCompatExcludeAttributeList>$(MSBuildThisFileDirectory)DefaultGenApiDocIds.txt</ApiCompatExcludeAttributeList>
3536
</PropertyGroup>
36-
37+
3738
<ItemGroup>
3839
<ProjectReference
3940
Condition="'$(UseMLCodeAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj'"
4041
Include="$(MSBuildThisFileDirectory)\..\tools-local\Microsoft.ML.InternalCodeAnalyzer\Microsoft.ML.InternalCodeAnalyzer.csproj">
4142
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
4243
<OutputItemType>Analyzer</OutputItemType>
4344
</ProjectReference>
44-
<PackageReference Condition="'$(UseStyleCopAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj'"
45-
Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="All" />
46-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0-beta2.final" PrivateAssets="All" />
4745
</ItemGroup>
4846

4947
<ItemGroup>

src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public interface ISingleFeaturePredictionTransformer<out TModel> : IPredictionTr
3636
}
3737

3838
/// <summary>
39-
/// An ISingleFeaturePredictionTransformer contains the name of the <see cref="FeatureColumnName"/>
40-
/// and its type, <see cref="FeatureColumnType"/>. Implementations of this interface, have the ability
41-
/// to score the data of an input <see cref="IDataView"/> through the <see cref="ITransformer.Transform(IDataView)"/>
39+
/// An ISingleFeaturePredictionTransformer contains the name of the <see cref="FeatureColumnName"/>.
40+
/// Implementations of this interface, have the ability to score the data of an input <see cref="IDataView"/>
41+
/// through the <see cref="ITransformer.Transform(IDataView)"/>
4242
/// </summary>
4343
[BestFriend]
4444
internal interface ISingleFeaturePredictionTransformer : ITransformer

src/Native/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ if(WIN32)
3636
add_compile_options(/fp:precise)
3737
add_compile_options(/EHsc)
3838

39+
# From here below are warnings required to be explicitly enabled.
40+
add_compile_options(/w34242)
41+
add_compile_options(/w34244)
42+
add_compile_options(/w34510)
43+
add_compile_options(/w34610)
44+
add_compile_options(/w34611)
45+
add_compile_options(/w34700)
46+
add_compile_options(/w34701)
47+
add_compile_options(/w34703)
48+
3949
if ($ENV{__BuildArch} STREQUAL "x86")
4050
add_compile_options(/Gz)
4151
endif ()
@@ -205,7 +215,7 @@ if (${ARCHITECTURE} STREQUAL "arm")
205215
add_compile_options(-mthumb)
206216
add_compile_options(-fPIC)
207217
add_compile_options(-march=armv7-a)
208-
218+
209219
if (NOT DEFINED CLR_ARM_FPU_TYPE)
210220
set (CLR_ARM_FPU_TYPE vfpv3)
211221
endif (NOT DEFINED CLR_ARM_FPU_TYPE)

src/Native/FastTreeNative/segment.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
EXPORT_API(void) C_SegmentFindOptimalPath15(_In_reads_(valc) unsigned long* valv, _In_ long valc, _Inout_ long long* pBits, _Inout_ long* pTransitions)
1515
{
1616
unsigned long transmap, bitindex = 0, bestindex = 0;
17-
short bestcost;
17+
int bestcost;
1818
long long bits = 40;
1919

2020
// Get the preallocated memory.
@@ -46,6 +46,7 @@ EXPORT_API(void) C_SegmentFindOptimalPath15(_In_reads_(valc) unsigned long* valv
4646
// Calculate the min cost position in the current iteration.
4747
bestcost = _mm_extract_epi16(_mm_minpos_epu16(_mm_min_epu16(
4848
_mm_cvtepi8_epi16(state0f), _mm_cvtepi8_epi16(_mm_srli_si128(state0f, 8)))), 0);
49+
4950
// Keep the invariant that the min cost position has 0 cost.
5051
state0f = _mm_or_si128(mask, _mm_sub_epi8(state0f, _mm_set1_epi8((char)bestcost)));
5152
// Find the bit index of the best position.
@@ -76,7 +77,7 @@ EXPORT_API(void) C_SegmentFindOptimalPath15(_In_reads_(valc) unsigned long* valv
7677
EXPORT_API(void) C_SegmentFindOptimalPath21(_In_reads_(valc) unsigned long* valv, _In_ long valc, _Inout_ long long* pBits, _Inout_ long* pTransitions)
7778
{
7879
unsigned long transmap, bitindex = 0, bestindex = 0;
79-
short bestcost;
80+
int bestcost;
8081
long long bits = 40;
8182
unsigned long* end = valv + valc;
8283

@@ -133,6 +134,7 @@ EXPORT_API(void) C_SegmentFindOptimalPath21(_In_reads_(valc) unsigned long* valv
133134
bestcost = _mm_extract_epi16(_mm_minpos_epu16(_mm_min_epu16(
134135
_mm_min_epu16(_mm_cvtepi8_epi16(statelo), _mm_cvtepi8_epi16(_mm_srli_si128(statelo, 8))),
135136
_mm_min_epu16(_mm_cvtepi8_epi16(statehi), _mm_cvtepi8_epi16(_mm_srli_si128(statehi, 8))))), 0);
137+
136138
// Keep the invariant that the min cost position has 0 cost.
137139
statelo = _mm_or_si128(masklo, _mm_sub_epi8(statelo, _mm_set1_epi8((char)bestcost)));
138140
statehi = _mm_or_si128(maskhi, _mm_sub_epi8(statehi, _mm_set1_epi8((char)bestcost)));
@@ -169,7 +171,7 @@ EXPORT_API(void) C_SegmentFindOptimalPath7(_In_reads_(valc) unsigned long* valv,
169171
// faster than the 15-bit version of this function, but this does
170172
// not seem to actually be the case? This should be improved.
171173
unsigned long transmap, bitindex = 0, bestindex = 0;
172-
short bestcost;
174+
int bestcost;
173175
long long bits = 40;
174176
unsigned long* end = valv + valc;
175177

@@ -205,8 +207,9 @@ EXPORT_API(void) C_SegmentFindOptimalPath7(_In_reads_(valc) unsigned long* valv,
205207
__m128i min = _mm_minpos_epu16(state0f);
206208
bestcost = _mm_extract_epi16(min, 0);
207209
bestindex = _mm_extract_epi16(min, 1);
210+
208211
// Keep the invariant that the min cost position has 0 cost.
209-
state0f = _mm_or_si128(mask, _mm_sub_epi8(state0f, _mm_set1_epi16(bestcost)));
212+
state0f = _mm_or_si128(mask, _mm_sub_epi8(state0f, _mm_set1_epi16((short)bestcost)));
210213
// Store the vital statistics.
211214
// [31,27]: best bit index
212215
// [26,22]: min bits to encoded current value (m)
@@ -260,9 +263,11 @@ EXPORT_API(void) C_SegmentFindOptimalCost15(_In_reads_(valc) unsigned int* valv,
260263
__m128i mask = _mm_load_si128(masksu + numbits);
261264
// Calculate the next base state of state0f.
262265
state0f = _mm_or_si128(mask, _mm_min_epu8(_mm_adds_epu8(state0f, stay), transition));
266+
263267
// Calculate the min cost position in the current iteration.
264-
short bestcost = _mm_extract_epi16(_mm_minpos_epu16(_mm_min_epu16(
268+
int bestcost = _mm_extract_epi16(_mm_minpos_epu16(_mm_min_epu16(
265269
_mm_cvtepi8_epi16(state0f), _mm_cvtepi8_epi16(_mm_srli_si128(state0f, 8)))), 0);
270+
266271
// Keep the invariant that the min cost position has 0 cost.
267272
state0f = _mm_or_si128(mask, _mm_sub_epi8(state0f, _mm_set1_epi8((char)bestcost)));
268273
// Find the position of the best position.
@@ -274,7 +279,7 @@ EXPORT_API(void) C_SegmentFindOptimalCost15(_In_reads_(valc) unsigned int* valv,
274279
EXPORT_API(void) C_SegmentFindOptimalCost31(_In_reads_(valc) unsigned long* valv, _In_ long valc, _Inout_ long long* pBits)
275280
{
276281
unsigned long bitindex = 0, bestindex = 0;
277-
short bestcost;
282+
int bestcost;
278283
long long bits = 40;
279284
unsigned long* end = valv + valc;
280285

@@ -318,6 +323,7 @@ EXPORT_API(void) C_SegmentFindOptimalCost31(_In_reads_(valc) unsigned long* valv
318323
bestcost = _mm_extract_epi16(_mm_minpos_epu16(_mm_min_epu16(
319324
_mm_min_epu16(_mm_cvtepi8_epi16(statelo), _mm_cvtepi8_epi16(_mm_srli_si128(statelo, 8))),
320325
_mm_min_epu16(_mm_cvtepi8_epi16(statehi), _mm_cvtepi8_epi16(_mm_srli_si128(statehi, 8))))), 0);
326+
321327
// Keep the invariant that the min cost position has 0 cost.
322328
statelo = _mm_or_si128(masklo, _mm_sub_epi8(statelo, _mm_set1_epi8((char)bestcost)));
323329
statehi = _mm_or_si128(maskhi, _mm_sub_epi8(statehi, _mm_set1_epi8((char)bestcost)));

test/Microsoft.Extensions.ML.Tests/UriLoaderTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public void can_reload_model()
4545
var sp = services.BuildServiceProvider();
4646

4747
var loaderUnderTest = ActivatorUtilities.CreateInstance<UriLoaderMock>(sp);
48-
loaderUnderTest.Start(new Uri("http://microsoft.com"), TimeSpan.FromMilliseconds(1));
48+
loaderUnderTest.Start(new Uri("https://microsoft.com"), TimeSpan.FromMilliseconds(1));
4949

5050
using AutoResetEvent changed = new AutoResetEvent(false);
5151
using IDisposable changeTokenRegistration = ChangeToken.OnChange(
5252
() => loaderUnderTest.GetReloadToken(),
5353
() => changed.Set());
54-
54+
5555
Assert.True(changed.WaitOne(AsyncTestHelper.UnexpectedTimeout), "UriLoader ChangeToken didn't fire before the allotted time.");
5656
}
5757

@@ -65,9 +65,9 @@ public void no_reload_no_change()
6565

6666
var loaderUnderTest = ActivatorUtilities.CreateInstance<UriLoaderMock>(sp);
6767

68-
loaderUnderTest.ETagMatches = (a,b) => true;
68+
loaderUnderTest.ETagMatches = (a, b) => true;
6969

70-
loaderUnderTest.Start(new Uri("http://microsoft.com"), TimeSpan.FromMilliseconds(1));
70+
loaderUnderTest.Start(new Uri("https://microsoft.com"), TimeSpan.FromMilliseconds(1));
7171

7272
using AutoResetEvent changed = new AutoResetEvent(false);
7373
using IDisposable changeTokenRegistration = ChangeToken.OnChange(

0 commit comments

Comments
 (0)