Skip to content

Commit 52d017f

Browse files
author
Глеб Брыкин
authored
Add files via upload
1 parent 5aae073 commit 52d017f

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

Implementation/src/MKL/Ops/Forward/AvgPool2d.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//* The code is available under the Apache-2.0 license. Read the License for details.
44
//***************************************************************************************************
55

6-
//-> Latest commit: Brykin Gleb, 22.03.2021
6+
//-> Latest commit: Brykin Gleb, 30.03.2021
77

88
using System;
99
using System.Threading;
@@ -66,10 +66,10 @@ public static void AvgPool2d(Half[] x, int[] x_shape, System.Tuple<int, int> ker
6666
{
6767
continue;
6868
}
69-
mean += x[((c * x_batch + b) * x_height + iy) * x_width + ix];
69+
mean += x[((b * x_channel + c) * x_height + iy) * x_width + ix];
7070
}
7171
}
72-
y[((c * y_batch + b) * y_height + oy) * y_width + ox] = mean / norm;
72+
y[((b * y_channel + c) * y_height + oy) * y_width + ox] = mean / norm;
7373
}
7474
}
7575
});
@@ -121,10 +121,10 @@ public static void AvgPool2d(float[] x, int[] x_shape, System.Tuple<int, int> ke
121121
{
122122
continue;
123123
}
124-
mean += x[((c * x_batch + b) * x_height + iy) * x_width + ix];
124+
mean += x[((b * x_channel + c) * x_height + iy) * x_width + ix];
125125
}
126126
}
127-
y[((c * y_batch + b) * y_height + oy) * y_width + ox] = mean / norm;
127+
y[((b * y_channel + c) * y_height + oy) * y_width + ox] = mean / norm;
128128
}
129129
}
130130
});
@@ -176,10 +176,10 @@ public static void AvgPool2d(double[] x, int[] x_shape, System.Tuple<int, int> k
176176
{
177177
continue;
178178
}
179-
mean += x[((c * x_batch + b) * x_height + iy) * x_width + ix];
179+
mean += x[((b * x_channel + c) * x_height + iy) * x_width + ix];
180180
}
181181
}
182-
y[((c * y_batch + b) * y_height + oy) * y_width + ox] = mean / norm;
182+
y[((b * y_channel + c) * y_height + oy) * y_width + ox] = mean / norm;
183183
}
184184
}
185185
});

Implementation/src/MKL/Ops/Forward/MaxPool2d.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//* The code is available under the Apache-2.0 license. Read the License for details.
44
//***************************************************************************************************
55

6-
//-> Latest commit: Brykin Gleb, 22.01.2021
6+
//-> Latest commit: Brykin Gleb, 30.03.2021
77

88
using System;
99
using System.Threading;
@@ -66,7 +66,7 @@ public static void MaxPool2d(Half[] x, int[] x_shape, System.Tuple<int, int> ker
6666
{
6767
continue;
6868
}
69-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
69+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
7070
var v = x[i];
7171
if(v > max)
7272
{
@@ -75,7 +75,7 @@ public static void MaxPool2d(Half[] x, int[] x_shape, System.Tuple<int, int> ker
7575
}
7676
}
7777
}
78-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
78+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
7979
y[index] = max;
8080
indices[index] = max_i;
8181
}
@@ -129,7 +129,7 @@ public static void MaxPool2d(float[] x, int[] x_shape, System.Tuple<int, int> ke
129129
{
130130
continue;
131131
}
132-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
132+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
133133
var v = x[i];
134134
if(v > max)
135135
{
@@ -138,7 +138,7 @@ public static void MaxPool2d(float[] x, int[] x_shape, System.Tuple<int, int> ke
138138
}
139139
}
140140
}
141-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
141+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
142142
y[index] = max;
143143
indices[index] = max_i;
144144
}
@@ -192,7 +192,7 @@ public static void MaxPool2d(double[] x, int[] x_shape, System.Tuple<int, int> k
192192
{
193193
continue;
194194
}
195-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
195+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
196196
var v = x[i];
197197
if(v > max)
198198
{
@@ -201,7 +201,7 @@ public static void MaxPool2d(double[] x, int[] x_shape, System.Tuple<int, int> k
201201
}
202202
}
203203
}
204-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
204+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
205205
y[index] = max;
206206
indices[index] = max_i;
207207
}
@@ -255,7 +255,7 @@ public static void MaxPool2d(byte[] x, int[] x_shape, System.Tuple<int, int> ker
255255
{
256256
continue;
257257
}
258-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
258+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
259259
var v = x[i];
260260
if(v > max)
261261
{
@@ -264,7 +264,7 @@ public static void MaxPool2d(byte[] x, int[] x_shape, System.Tuple<int, int> ker
264264
}
265265
}
266266
}
267-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
267+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
268268
y[index] = max;
269269
indices[index] = max_i;
270270
}
@@ -318,7 +318,7 @@ public static void MaxPool2d(sbyte[] x, int[] x_shape, System.Tuple<int, int> ke
318318
{
319319
continue;
320320
}
321-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
321+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
322322
var v = x[i];
323323
if(v > max)
324324
{
@@ -327,7 +327,7 @@ public static void MaxPool2d(sbyte[] x, int[] x_shape, System.Tuple<int, int> ke
327327
}
328328
}
329329
}
330-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
330+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
331331
y[index] = max;
332332
indices[index] = max_i;
333333
}
@@ -381,7 +381,7 @@ public static void MaxPool2d(short[] x, int[] x_shape, System.Tuple<int, int> ke
381381
{
382382
continue;
383383
}
384-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
384+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
385385
var v = x[i];
386386
if(v > max)
387387
{
@@ -390,7 +390,7 @@ public static void MaxPool2d(short[] x, int[] x_shape, System.Tuple<int, int> ke
390390
}
391391
}
392392
}
393-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
393+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
394394
y[index] = max;
395395
indices[index] = max_i;
396396
}
@@ -444,7 +444,7 @@ public static void MaxPool2d(int[] x, int[] x_shape, System.Tuple<int, int> kern
444444
{
445445
continue;
446446
}
447-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
447+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
448448
var v = x[i];
449449
if(v > max)
450450
{
@@ -453,7 +453,7 @@ public static void MaxPool2d(int[] x, int[] x_shape, System.Tuple<int, int> kern
453453
}
454454
}
455455
}
456-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
456+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
457457
y[index] = max;
458458
indices[index] = max_i;
459459
}
@@ -507,7 +507,7 @@ public static void MaxPool2d(long[] x, int[] x_shape, System.Tuple<int, int> ker
507507
{
508508
continue;
509509
}
510-
var i = ((c * x_batch + b) * x_height + iy) * x_width + ix;
510+
var i = ((b * x_channel + c) * x_height + iy) * x_width + ix;
511511
var v = x[i];
512512
if(v > max)
513513
{
@@ -516,7 +516,7 @@ public static void MaxPool2d(long[] x, int[] x_shape, System.Tuple<int, int> ker
516516
}
517517
}
518518
}
519-
var index = ((c * y_batch + b) * y_height + oy) * y_width + ox;
519+
var index = ((b * y_channel + c) * y_height + oy) * y_width + ox;
520520
y[index] = max;
521521
indices[index] = max_i;
522522
}

0 commit comments

Comments
 (0)