@@ -117,13 +117,16 @@ internal static Vector128<float> GetNewDst128(in Vector128<float> xDst1, in Vect
117
117
// Multiply matrix times vector into vector.
118
118
public static unsafe void MatMul ( AlignedArray mat , AlignedArray src , AlignedArray dst , int crow , int ccol )
119
119
{
120
+ Contracts . Assert ( src . Size == dst . Size ) ;
121
+
120
122
MatMul ( mat . Items , src . Items , dst . Items , crow , ccol ) ;
121
123
}
122
124
123
125
public static unsafe void MatMul ( ReadOnlySpan < float > mat , ReadOnlySpan < float > src , Span < float > dst , int crow , int ccol )
124
126
{
125
127
Contracts . Assert ( crow % 4 == 0 ) ;
126
128
Contracts . Assert ( ccol % 4 == 0 ) ;
129
+ Contracts . Assert ( src . Length == dst . Length ) ;
127
130
128
131
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
129
132
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
@@ -279,12 +282,15 @@ public static unsafe void MatMul(ReadOnlySpan<float> mat, ReadOnlySpan<float> sr
279
282
public static unsafe void MatMulP ( AlignedArray mat , ReadOnlySpan < int > rgposSrc , AlignedArray src ,
280
283
int posMin , int iposMin , int iposEnd , AlignedArray dst , int crow , int ccol )
281
284
{
285
+ Contracts . Assert ( src . Size == dst . Size ) ;
286
+
282
287
MatMulP ( mat . Items , rgposSrc , src . Items , posMin , iposMin , iposEnd , dst . Items , crow , ccol ) ;
283
288
}
284
289
285
290
public static unsafe void MatMulP ( ReadOnlySpan < float > mat , ReadOnlySpan < int > rgposSrc , ReadOnlySpan < float > src ,
286
291
int posMin , int iposMin , int iposEnd , Span < float > dst , int crow , int ccol )
287
292
{
293
+ Contracts . Assert ( src . Length == dst . Length ) ;
288
294
Contracts . Assert ( crow % 4 == 0 ) ;
289
295
Contracts . Assert ( ccol % 4 == 0 ) ;
290
296
@@ -443,11 +449,14 @@ Vector128<float> SparseMultiplicationAcrossRow()
443
449
444
450
public static unsafe void MatMulTran ( AlignedArray mat , AlignedArray src , AlignedArray dst , int crow , int ccol )
445
451
{
452
+ Contracts . Assert ( src . Size == dst . Size ) ;
453
+
446
454
MatMulTran ( mat . Items , src . Items , dst . Items , crow , ccol ) ;
447
455
}
448
456
449
457
public static unsafe void MatMulTran ( ReadOnlySpan < float > mat , ReadOnlySpan < float > src , Span < float > dst , int crow , int ccol )
450
458
{
459
+ Contracts . Assert ( src . Length == dst . Length ) ;
451
460
Contracts . Assert ( crow % 4 == 0 ) ;
452
461
Contracts . Assert ( ccol % 4 == 0 ) ;
453
462
@@ -893,6 +902,8 @@ public static unsafe void Scale(float scale, Span<float> dst)
893
902
894
903
public static unsafe void ScaleSrcU ( float scale , ReadOnlySpan < float > src , Span < float > dst , int count )
895
904
{
905
+ Contracts . Assert ( src . Length == dst . Length ) ;
906
+
896
907
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
897
908
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
898
909
{
@@ -961,6 +972,8 @@ public static unsafe void ScaleAddU(float a, float b, Span<float> dst)
961
972
962
973
public static unsafe void AddScaleU ( float scale , ReadOnlySpan < float > src , Span < float > dst , int count )
963
974
{
975
+ Contracts . Assert ( src . Length == dst . Length ) ;
976
+
964
977
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
965
978
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
966
979
{
@@ -1000,6 +1013,8 @@ public static unsafe void AddScaleU(float scale, ReadOnlySpan<float> src, Span<f
1000
1013
1001
1014
public static unsafe void AddScaleCopyU ( float scale , ReadOnlySpan < float > src , ReadOnlySpan < float > dst , Span < float > result , int count )
1002
1015
{
1016
+ Contracts . Assert ( src . Length == dst . Length ) ;
1017
+
1003
1018
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1004
1019
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
1005
1020
fixed ( float * pres = & MemoryMarshal . GetReference ( result ) )
@@ -1041,6 +1056,8 @@ public static unsafe void AddScaleCopyU(float scale, ReadOnlySpan<float> src, Re
1041
1056
1042
1057
public static unsafe void AddScaleSU ( float scale , ReadOnlySpan < float > src , ReadOnlySpan < int > idx , Span < float > dst , int count )
1043
1058
{
1059
+ Contracts . Assert ( src . Length == dst . Length ) ;
1060
+
1044
1061
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1045
1062
fixed ( int * pidx = & MemoryMarshal . GetReference ( idx ) )
1046
1063
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
@@ -1077,6 +1094,8 @@ public static unsafe void AddScaleSU(float scale, ReadOnlySpan<float> src, ReadO
1077
1094
1078
1095
public static unsafe void AddU ( ReadOnlySpan < float > src , Span < float > dst , int count )
1079
1096
{
1097
+ Contracts . Assert ( src . Length == dst . Length ) ;
1098
+
1080
1099
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1081
1100
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
1082
1101
{
@@ -1112,6 +1131,8 @@ public static unsafe void AddU(ReadOnlySpan<float> src, Span<float> dst, int cou
1112
1131
1113
1132
public static unsafe void AddSU ( ReadOnlySpan < float > src , ReadOnlySpan < int > idx , Span < float > dst , int count )
1114
1133
{
1134
+ Contracts . Assert ( src . Length == dst . Length ) ;
1135
+
1115
1136
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1116
1137
fixed ( int * pidx = & MemoryMarshal . GetReference ( idx ) )
1117
1138
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
@@ -1145,6 +1166,9 @@ public static unsafe void AddSU(ReadOnlySpan<float> src, ReadOnlySpan<int> idx,
1145
1166
1146
1167
public static unsafe void MulElementWiseU ( ReadOnlySpan < float > src1 , ReadOnlySpan < float > src2 , Span < float > dst , int count )
1147
1168
{
1169
+ Contracts . Assert ( src1 . Length == dst . Length ) ;
1170
+ Contracts . Assert ( src2 . Length == dst . Length ) ;
1171
+
1148
1172
fixed ( float * psrc1 = & MemoryMarshal . GetReference ( src1 ) )
1149
1173
fixed ( float * psrc2 = & MemoryMarshal . GetReference ( src2 ) )
1150
1174
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
@@ -1479,6 +1503,8 @@ public static unsafe float MaxAbsDiffU(float mean, ReadOnlySpan<float> src)
1479
1503
1480
1504
public static unsafe float DotU ( ReadOnlySpan < float > src , ReadOnlySpan < float > dst , int count )
1481
1505
{
1506
+ Contracts . Assert ( src . Length == dst . Length ) ;
1507
+
1482
1508
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1483
1509
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
1484
1510
{
@@ -1518,6 +1544,8 @@ public static unsafe float DotU(ReadOnlySpan<float> src, ReadOnlySpan<float> dst
1518
1544
1519
1545
public static unsafe float DotSU ( ReadOnlySpan < float > src , ReadOnlySpan < float > dst , ReadOnlySpan < int > idx , int count )
1520
1546
{
1547
+ Contracts . Assert ( src . Length == dst . Length ) ;
1548
+
1521
1549
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1522
1550
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
1523
1551
fixed ( int * pidx = & MemoryMarshal . GetReference ( idx ) )
@@ -1559,6 +1587,8 @@ public static unsafe float DotSU(ReadOnlySpan<float> src, ReadOnlySpan<float> ds
1559
1587
1560
1588
public static unsafe float Dist2 ( ReadOnlySpan < float > src , ReadOnlySpan < float > dst , int count )
1561
1589
{
1590
+ Contracts . Assert ( src . Length == dst . Length ) ;
1591
+
1562
1592
fixed ( float * psrc = & MemoryMarshal . GetReference ( src ) )
1563
1593
fixed ( float * pdst = & MemoryMarshal . GetReference ( dst ) )
1564
1594
{
0 commit comments