Skip to content

Commit 287bc3e

Browse files
authored
Reverting dead unallignedCode paths (#1845)
* reverting dead unallignedCode paths * timeSeries alignment corrected for avx, multiplyadd added, performance tests done for odd input, enabled timeseries tests * name corrected
1 parent 4e8ad35 commit 287bc3e

File tree

14 files changed

+869
-2225
lines changed

14 files changed

+869
-2225
lines changed

src/Microsoft.ML.CpuMath/AvxIntrinsics.cs

Lines changed: 160 additions & 524 deletions
Large diffs are not rendered by default.

src/Microsoft.ML.CpuMath/CpuMathUtils.netstandard.cs

Lines changed: 383 additions & 28 deletions
Large diffs are not rendered by default.

src/Microsoft.ML.CpuMath/Sse.cs

Lines changed: 0 additions & 427 deletions
This file was deleted.

src/Microsoft.ML.CpuMath/SseIntrinsics.cs

Lines changed: 129 additions & 520 deletions
Large diffs are not rendered by default.

src/Microsoft.ML.TimeSeries/AdaptiveSingularSpectrumSequenceModeler.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Globalization;
8-
using System.Linq;
97
using System.Numerics;
108
using Microsoft.ML.Runtime;
119
using Microsoft.ML.Runtime.Data;
@@ -290,8 +288,8 @@ public AdaptiveSingularSpectrumSequenceModeler(IHostEnvironment env, int trainSi
290288

291289
_alpha = new Single[windowSize - 1];
292290
_state = new Single[windowSize - 1];
293-
_x = new CpuAlignedVector(windowSize, SseUtils.CbAlign);
294-
_xSmooth = new CpuAlignedVector(windowSize, SseUtils.CbAlign);
291+
_x = new CpuAlignedVector(windowSize, CpuMathUtils.GetVectorAlignment());
292+
_xSmooth = new CpuAlignedVector(windowSize, CpuMathUtils.GetVectorAlignment());
295293
ShouldComputeForecastIntervals = shouldComputeForecastIntervals;
296294

297295
_observationNoiseVariance = 0;
@@ -345,13 +343,13 @@ private AdaptiveSingularSpectrumSequenceModeler(AdaptiveSingularSpectrumSequence
345343
_state = new Single[_windowSize - 1];
346344
Array.Copy(model._state, _state, _windowSize - 1);
347345

348-
_x = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
349-
_xSmooth = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
346+
_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
347+
_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
350348

351349
if (model._wTrans != null)
352350
{
353-
_y = new CpuAlignedVector(_rank, SseUtils.CbAlign);
354-
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, SseUtils.CbAlign);
351+
_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment());
352+
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment());
355353
_wTrans.CopyFrom(model._wTrans);
356354
}
357355
}
@@ -452,18 +450,18 @@ public AdaptiveSingularSpectrumSequenceModeler(IHostEnvironment env, ModelLoadCo
452450
{
453451
var tempArray = ctx.Reader.ReadFloatArray();
454452
_host.CheckDecode(Utils.Size(tempArray) == _rank * _windowSize);
455-
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, SseUtils.CbAlign);
453+
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment());
456454
int i = 0;
457455
_wTrans.CopyFrom(tempArray, ref i);
458456
tempArray = ctx.Reader.ReadFloatArray();
459457
i = 0;
460-
_y = new CpuAlignedVector(_rank, SseUtils.CbAlign);
458+
_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment());
461459
_y.CopyFrom(tempArray, ref i);
462460
}
463461

464462
_buffer = TimeSeriesUtils.DeserializeFixedSizeQueueSingle(ctx.Reader, _host);
465-
_x = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
466-
_xSmooth = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
463+
_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
464+
_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
467465
}
468466

469467
public override void Save(ModelSaveContext ctx)
@@ -1130,8 +1128,8 @@ internal override void Consume(ref Single input, bool updateModel = false)
11301128

11311129
if (_wTrans == null)
11321130
{
1133-
_y = new CpuAlignedVector(_rank, SseUtils.CbAlign);
1134-
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, SseUtils.CbAlign);
1131+
_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment());
1132+
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment());
11351133
Single[] vecs = new Single[_rank * _windowSize];
11361134

11371135
for (i = 0; i < _rank; ++i)
@@ -1311,8 +1309,8 @@ private void TrainCore(Single[] dataArray, int originalSeriesLength)
13111309
_maxRank = _windowSize / 2;
13121310
_alpha = new Single[_windowSize - 1];
13131311
_state = new Single[_windowSize - 1];
1314-
_x = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
1315-
_xSmooth = new CpuAlignedVector(_windowSize, SseUtils.CbAlign);
1312+
_x = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
1313+
_xSmooth = new CpuAlignedVector(_windowSize, CpuMathUtils.GetVectorAlignment());
13161314

13171315
TrainCore(dataArray, originalSeriesLength);
13181316
return;
@@ -1349,10 +1347,10 @@ private void TrainCore(Single[] dataArray, int originalSeriesLength)
13491347
}
13501348

13511349
// Setting the the y vector
1352-
_y = new CpuAlignedVector(_rank, SseUtils.CbAlign);
1350+
_y = new CpuAlignedVector(_rank, CpuMathUtils.GetVectorAlignment());
13531351

13541352
// Setting the weight matrix
1355-
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, SseUtils.CbAlign);
1353+
_wTrans = new CpuAlignedMatrixRow(_rank, _windowSize, CpuMathUtils.GetVectorAlignment());
13561354
i = 0;
13571355
_wTrans.CopyFrom(leftSingularVecs, ref i);
13581356

0 commit comments

Comments
 (0)