public static Quaternion.QuaternionFilter2D Reference(TrivectorMap2D x, TrivectorMap2D gy, Quaternion.QuaternionFilter2D w, int kwidth, int kheight, int stride) { int inchannels = x.Channels, outchannels = gy.Channels, batch = x.Batch; int inw = x.Width, inh = x.Height, outw = gy.Width, outh = gy.Height; if (outw != (inw - kwidth) / stride + 1 || outh != (inh - kheight) / stride + 1) { throw new ArgumentException("mismatch shape"); } Quaternion.QuaternionFilter2D gw = new Quaternion.QuaternionFilter2D(inchannels, outchannels, kwidth, kheight); for (int kx, ky = 0; ky < kheight; ky++) { for (kx = 0; kx < kwidth; kx++) { for (int th = 0; th < batch; th++) { for (int inch, outch = 0; outch < outchannels; outch++) { for (inch = 0; inch < inchannels; inch++) { Quaternion.Quaternion sum = 0; Quaternion.Quaternion q = w[inch, outch, kx, ky]; for (int ix, iy = ky, ox, oy = 0; oy < outh; iy += stride, oy++) { for (ix = kx, ox = 0; ox < outw; ix += stride, ox++) { sum += Trivector.MulQGrad(x[inch, ix, iy, th], gy[outch, ox, oy, th], q); } } gw[inch, outch, kx, ky] += sum; } } } } } return(gw); }
public static TrivectorMap2D Reference(TrivectorMap2D y, Quaternion.QuaternionFilter2D w, int inw, int inh, int kwidth, int kheight, int stride) { int inchannels = w.InChannels, outchannels = w.OutChannels, batch = y.Batch; int outw = (inw - kwidth) / stride + 1, outh = (inh - kheight) / stride + 1; if (y.Width != outw || y.Height != outh) { throw new ArgumentException("mismatch shape"); } TrivectorMap2D x = new TrivectorMap2D(inchannels, inw, inh, batch); for (int kx, ky = 0; ky < kheight; ky++) { for (kx = 0; kx < kwidth; kx++) { for (int th = 0; th < batch; th++) { for (int ox, oy = 0; oy < outh; oy++) { for (ox = 0; ox < outw; ox++) { for (int outch = 0; outch < outchannels; outch++) { Trivector v = y[outch, ox, oy, th]; for (int inch = 0; inch < inchannels; inch++) { x[inch, kx + ox * stride, ky + oy * stride, th] += v * w[inch, outch, kx, ky]; } } } } } } } return(x); }
public static TrivectorMap2D Reference(TrivectorMap2D x, Quaternion.QuaternionFilter2D w, int kwidth, int kheight, int stride) { int inchannels = x.Channels, outchannels = w.OutChannels, batch = x.Batch; int inw = x.Width, inh = x.Height; int outw = (inw - kwidth) / stride + 1, outh = (inh - kheight) / stride + 1; TrivectorMap2D y = new TrivectorMap2D(outchannels, outw, outh, batch); for (int kx, ky = 0; ky < kheight; ky++) { for (kx = 0; kx < kwidth; kx++) { for (int th = 0; th < batch; th++) { for (int ox, oy = 0; oy < outh; oy++) { for (ox = 0; ox < outw; ox++) { for (int outch = 0; outch < outchannels; outch++) { Trivector sum = y[outch, ox, oy, th]; for (int inch = 0; inch < inchannels; inch++) { sum += x[inch, kx + ox * stride, ky + oy * stride, th] * w[inch, outch, kx, ky]; } y[outch, ox, oy, th] = sum; } } } } } } return(y); }
public void ExecuteTest() { float max_err = 0; foreach (int batch in new int[] { 1, 2, 3 }) { foreach (int inchannels in new int[] { 3, 6, 9, 12 }) { foreach (int outchannels in new int[] { 3, 6, 9, 12 }) { foreach (int kheight in new int[] { 1, 3, 5 }) { foreach (int kwidth in new int[] { 1, 3, 5 }) { foreach (int stride in new int[] { 1, 2, 3 }) { foreach (int inwidth in new int[] { 8, 9, 13, 17 }) { foreach (int inheight in new int[] { 8, 9, 19, 23 }) { int outwidth = (inwidth - kwidth) / stride + 1, outheight = (inheight - kheight) / stride + 1; float[] xval = (new float[inwidth * inheight * inchannels * batch]).Select((_, idx) => idx * 1e-3f).ToArray(); float[] yval = (new float[outwidth * outheight * outchannels * batch]).Select((_, idx) => idx * 1e-3f).Reverse().ToArray(); float[] wval = (new float[kwidth * kheight * inchannels * outchannels / 9 * 4]).Select((_, idx) => idx * 1e-3f).Reverse().ToArray(); Trivector[] xcval = (new Trivector[xval.Length / 3]) .Select((_, idx) => new Trivector(xval[idx * 3], xval[idx * 3 + 1], xval[idx * 3 + 2])).ToArray(); Trivector[] ycval = (new Trivector[yval.Length / 3]) .Select((_, idx) => new Trivector(yval[idx * 3], yval[idx * 3 + 1], yval[idx * 3 + 2])).ToArray(); Quaternion.Quaternion[] wcval = (new Quaternion.Quaternion[wval.Length / 4]) .Select((_, idx) => new Quaternion.Quaternion(wval[idx * 4], wval[idx * 4 + 1], wval[idx * 4 + 2], wval[idx * 4 + 3])).ToArray(); TrivectorMap2D x = new TrivectorMap2D(inchannels / 3, inwidth, inheight, batch, xcval); TrivectorMap2D y = new TrivectorMap2D(outchannels / 3, outwidth, outheight, batch, ycval); Quaternion.QuaternionFilter2D w = new Quaternion.QuaternionFilter2D(inchannels / 3, outchannels / 3, kwidth, kheight, wcval); Quaternion.QuaternionFilter2D gw = Reference(x, y, w, kwidth, kheight, stride); OverflowCheckedTensor x_tensor = new OverflowCheckedTensor(Shape.Map2D(inchannels, inwidth, inheight, batch), xval); OverflowCheckedTensor y_tensor = new OverflowCheckedTensor(Shape.Map2D(outchannels, outwidth, outheight, batch), yval); OverflowCheckedTensor w_tensor = new OverflowCheckedTensor(Shape.Kernel2D(inchannels / 3 * 4, outchannels / 3, kwidth, kheight), wval); OverflowCheckedTensor gw_tensor = new OverflowCheckedTensor(Shape.Kernel2D(inchannels / 3 * 4, outchannels / 3, kwidth, kheight)); TrivectorKernelProduct2D ope = new TrivectorKernelProduct2D(inwidth, inheight, inchannels, outchannels, kwidth, kheight, stride, transpose: false, batch); ope.Execute(x_tensor, y_tensor, w_tensor, gw_tensor); float[] gw_expect = gw.ToArray(); float[] gw_actual = gw_tensor.State; CollectionAssert.AreEqual(xval, x_tensor.State); CollectionAssert.AreEqual(yval, y_tensor.State); CollectionAssert.AreEqual(wval, w_tensor.State); AssertError.Tolerance(gw_expect, gw_actual, 1e-7f, 1e-5f, ref max_err, $"mismatch value {inchannels},{outchannels},{kwidth},{kheight},{stride},{inwidth},{inheight},{batch}"); Console.WriteLine($"pass: {inchannels},{outchannels},{kwidth},{kheight},{stride},{inwidth},{inheight},{batch}"); } } } } } } } } Console.WriteLine($"maxerr:{max_err}"); }
public void ReferenceTest() { int inchannels = 9, outchannels = 12, kwidth = 3, kheight = 5, stride = 2, inwidth = 7, inheight = 8, batch = 3; int outwidth = (inwidth - kwidth) / stride + 1, outheight = (inheight - kheight) / stride + 1; float[] yval = (new float[outwidth * outheight * outchannels * batch]).Select((_, idx) => idx * 1e-3f).ToArray(); float[] wval = (new float[kwidth * kheight * outchannels * inchannels / 9 * 4]).Select((_, idx) => idx * 1e-3f).Reverse().ToArray(); Trivector[] ycval = (new Trivector[yval.Length / 3]) .Select((_, idx) => new Trivector(yval[idx * 3], yval[idx * 3 + 1], yval[idx * 3 + 2])).ToArray(); Quaternion.Quaternion[] wcval = (new Quaternion.Quaternion[wval.Length / 4]) .Select((_, idx) => new Quaternion.Quaternion(wval[idx * 4], wval[idx * 4 + 1], wval[idx * 4 + 2], wval[idx * 4 + 3])).ToArray(); TrivectorMap2D y = new TrivectorMap2D(outchannels / 3, outwidth, outheight, batch, ycval); Quaternion.QuaternionFilter2D w = new Quaternion.QuaternionFilter2D(inchannels / 3, outchannels / 3, kwidth, kheight, wcval); TrivectorMap2D x = Reference(y, w, inwidth, inheight, kwidth, kheight, stride); float[] x_expect = { 4.999796400e-02f, 3.415198800e-02f, 4.201750800e-02f, 4.942282800e-02f, 3.375646800e-02f, 4.153251600e-02f, 4.885102000e-02f, 3.336325200e-02f, 4.105034000e-02f, 4.331598000e-02f, 2.955781200e-02f, 3.638346000e-02f, 4.278078000e-02f, 2.918994000e-02f, 3.593226000e-02f, 4.224890800e-02f, 2.882437200e-02f, 3.548387600e-02f, 1.813600560e-01f, 1.532930640e-01f, 1.670186640e-01f, 1.792167600e-01f, 1.514867280e-01f, 1.650456720e-01f, 1.770862640e-01f, 1.496911440e-01f, 1.630844560e-01f, 1.250955960e-01f, 1.109618760e-01f, 1.177881000e-01f, 1.235612280e-01f, 1.095971400e-01f, 1.163400360e-01f, 1.220363320e-01f, 1.082408520e-01f, 1.149009320e-01f, 3.458040240e-01f, 3.169859280e-01f, 3.307126800e-01f, 3.416623920e-01f, 3.131858640e-01f, 3.267459600e-01f, 3.375458480e-01f, 3.094088400e-01f, 3.228033040e-01f, 2.068752120e-01f, 1.923659400e-01f, 1.991927400e-01f, 2.043416760e-01f, 1.900043400e-01f, 1.967478120e-01f, 2.018237560e-01f, 1.876573320e-01f, 1.943179880e-01f, 1.775034360e-01f, 1.649898120e-01f, 1.708504680e-01f, 1.751572920e-01f, 1.628033160e-01f, 1.685867880e-01f, 1.728267640e-01f, 1.606314120e-01f, 1.663382120e-01f, 3.138970800e-02f, 2.136478800e-02f, 2.633187600e-02f, 3.093438000e-02f, 2.105221200e-02f, 2.594826000e-02f, 3.048238000e-02f, 2.074194000e-02f, 2.556746000e-02f, 2.614542000e-02f, 1.776594000e-02f, 2.191434000e-02f, 2.573002800e-02f, 1.748101200e-02f, 2.156451600e-02f, 2.531796400e-02f, 1.719838800e-02f, 2.121750800e-02f, 1.122654000e-01f, 9.503872800e-02f, 1.034098320e-01f, 1.105829040e-01f, 9.361946400e-02f, 1.018607760e-01f, 1.089132080e-01f, 9.221095200e-02f, 1.003234960e-01f, 7.582570800e-02f, 6.715362000e-02f, 7.130259600e-02f, 7.463233200e-02f, 6.609301200e-02f, 7.017709200e-02f, 7.344842800e-02f, 6.504085200e-02f, 6.906054800e-02f, 2.125107120e-01f, 1.946988240e-01f, 2.030710800e-01f, 2.092722480e-01f, 1.917282000e-01f, 1.999706640e-01f, 2.060588720e-01f, 1.887806160e-01f, 1.968943120e-01f, 1.255059960e-01f, 1.165413000e-01f, 1.206908520e-01f, 1.235346360e-01f, 1.147050120e-01f, 1.187896680e-01f, 1.215788920e-01f, 1.128833160e-01f, 1.169035880e-01f, 1.028803320e-01f, 9.546891600e-02f, 9.887350800e-02f, 1.010963640e-01f, 9.380773200e-02f, 9.715357200e-02f, 9.932801200e-02f, 9.216114000e-02f, 9.544874000e-02f, 3.498390960e-01f, 3.272525520e-01f, 3.378520080e-01f, 3.457097520e-01f, 3.234156240e-01f, 3.338730000e-01f, 3.416054960e-01f, 3.196017360e-01f, 3.299180560e-01f, 3.019427760e-01f, 2.827300560e-01f, 2.916921360e-01f, 2.981144880e-01f, 2.791696080e-01f, 2.880018960e-01f, 2.943112880e-01f, 2.756322000e-01f, 2.843357200e-01f, 7.344515040e-01f, 6.950906400e-01f, 7.131634080e-01f, 7.250915040e-01f, 6.862709280e-01f, 7.040841120e-01f, 7.157939680e-01f, 6.775095840e-01f, 6.950652320e-01f, 4.092659760e-01f, 3.894680400e-01f, 3.984312720e-01f, 4.038817200e-01f, 3.843562320e-01f, 3.931896720e-01f, 3.985348400e-01f, 3.792797520e-01f, 3.879844240e-01f, 9.508673760e-01f, 9.103360800e-01f, 9.284111520e-01f, 9.383954400e-01f, 8.984136480e-01f, 9.162291360e-01f, 9.260105440e-01f, 8.865741600e-01f, 9.041321120e-01f, 5.165891760e-01f, 4.962060240e-01f, 5.051704080e-01f, 5.096489520e-01f, 4.895428560e-01f, 4.983774480e-01f, 5.027583920e-01f, 4.829273040e-01f, 4.916331280e-01f, 4.365843120e-01f, 4.193906640e-01f, 4.268651280e-01f, 4.302400560e-01f, 4.132988880e-01f, 4.206558480e-01f, 4.239454640e-01f, 4.072547280e-01f, 4.144952080e-01f, 2.169881520e-01f, 2.036383440e-01f, 2.097680400e-01f, 2.137619760e-01f, 2.006308560e-01f, 2.066553360e-01f, 2.105608880e-01f, 1.976464080e-01f, 2.035666960e-01f, 1.799298480e-01f, 1.690691280e-01f, 1.740038160e-01f, 1.770047280e-01f, 1.663381200e-01f, 1.711798800e-01f, 1.741046960e-01f, 1.636301520e-01f, 1.683800080e-01f, 4.368438240e-01f, 4.143528480e-01f, 4.243708320e-01f, 4.297325280e-01f, 4.076343840e-01f, 4.174665120e-01f, 4.226836960e-01f, 4.009742880e-01f, 4.106226080e-01f, 2.389796400e-01f, 2.276995920e-01f, 2.326354320e-01f, 2.349409200e-01f, 2.238595920e-01f, 2.287025040e-01f, 2.309395760e-01f, 2.200549200e-01f, 2.248059280e-01f, 5.567128800e-01f, 5.333832480e-01f, 5.434035360e-01f, 5.473743840e-01f, 5.244468000e-01f, 5.342812320e-01f, 5.381229280e-01f, 5.155932960e-01f, 5.252439200e-01f, 2.980294320e-01f, 2.863300560e-01f, 2.912670480e-01f, 2.928771120e-01f, 2.813810640e-01f, 2.862251280e-01f, 2.877744560e-01f, 2.764796880e-01f, 2.812318480e-01f, 2.394794160e-01f, 2.300848080e-01f, 2.339742480e-01f, 2.349230640e-01f, 2.257072080e-01f, 2.295160080e-01f, 2.304163760e-01f, 2.213772240e-01f, 2.251064080e-01f, 1.166512560e-01f, 1.098839760e-01f, 1.128710160e-01f, 1.143282480e-01f, 1.077059280e-01f, 1.106246160e-01f, 1.120303280e-01f, 1.055509200e-01f, 1.084022800e-01f, 9.043096800e-02f, 8.526804000e-02f, 8.750244000e-02f, 8.840901600e-02f, 8.336647200e-02f, 8.554480800e-02f, 8.641215200e-02f, 8.148794400e-02f, 8.361124000e-02f, 2.201894880e-01f, 2.092599840e-01f, 2.138773920e-01f, 2.153268960e-01f, 2.046427680e-01f, 2.091480480e-01f, 2.105267680e-01f, 2.000839200e-01f, 2.044791200e-01f, 1.171326000e-01f, 1.117162320e-01f, 1.139517840e-01f, 1.144394160e-01f, 1.091480400e-01f, 1.113275280e-01f, 1.117836080e-01f, 1.066151760e-01f, 1.087396240e-01f, 2.753622240e-01f, 2.639258400e-01f, 2.685455520e-01f, 2.691571680e-01f, 2.579753760e-01f, 2.624829600e-01f, 2.630391520e-01f, 2.521078560e-01f, 2.565053600e-01f, 1.438342320e-01f, 1.381644240e-01f, 1.404011280e-01f, 1.404698160e-01f, 1.349296080e-01f, 1.371102480e-01f, 1.371550640e-01f, 1.317424080e-01f, 1.338680080e-01f, 1.067390640e-01f, 1.024892880e-01f, 1.041208080e-01f, 1.039706160e-01f, 9.982586400e-02f, 1.014136080e-01f, 1.012518320e-01f, 9.721005600e-02f, 9.875504800e-02f, 4.874084400e-02f, 4.591362000e-02f, 4.707622800e-02f, 4.729710000e-02f, 4.454581200e-02f, 4.567424400e-02f, 4.587511600e-02f, 4.319874000e-02f, 4.429350800e-02f, 3.285207600e-02f, 3.086850000e-02f, 3.165478800e-02f, 3.166945200e-02f, 2.974952400e-02f, 3.050778000e-02f, 3.050858800e-02f, 2.865128400e-02f, 2.938202000e-02f, 8.271372000e-02f, 7.844474400e-02f, 8.009162400e-02f, 7.993912800e-02f, 7.579975200e-02f, 7.739056800e-02f, 7.721420000e-02f, 7.320237600e-02f, 7.473815200e-02f, 4.222158000e-02f, 4.011128400e-02f, 4.089814800e-02f, 4.070334000e-02f, 3.865899600e-02f, 3.941782800e-02f, 3.921300400e-02f, 3.723358800e-02f, 3.796490000e-02f, 1.023374640e-01f, 9.781504800e-02f, 9.946308000e-02f, 9.889164000e-02f, 9.450343200e-02f, 9.609540000e-02f, 9.550776800e-02f, 9.125172000e-02f, 9.278864800e-02f, 5.159108400e-02f, 4.935406800e-02f, 5.014150800e-02f, 4.973722800e-02f, 4.756846800e-02f, 4.832787600e-02f, 4.791742000e-02f, 4.581589200e-02f, 4.654778000e-02f, 3.159198000e-02f, 3.010645200e-02f, 3.059130000e-02f, 3.014670000e-02f, 2.871714000e-02f, 2.918010000e-02f, 2.873546800e-02f, 2.736085200e-02f, 2.780243600e-02f, 1.047486000e-02f, 9.736212000e-03f, 9.991044000e-03f, 9.814476000e-03f, 9.114900000e-03f, 9.353988000e-03f, 9.175852000e-03f, 8.514324000e-03f, 8.738180000e-03f, 3.986412000e-03f, 3.649044000e-03f, 3.748740000e-03f, 3.587148000e-03f, 3.276564000e-03f, 3.366660000e-03f, 3.209644000e-03f, 2.924820000e-03f, 3.005828000e-03f, 1.411672800e-02f, 1.322311200e-02f, 1.349680800e-02f, 1.313004000e-02f, 1.229229600e-02f, 1.254679200e-02f, 1.219301600e-02f, 1.140909600e-02f, 1.164541600e-02f, 5.144460000e-03f, 4.763316000e-03f, 4.863588000e-03f, 4.630764000e-03f, 4.278708000e-03f, 4.369380000e-03f, 4.144972000e-03f, 3.820980000e-03f, 3.902564000e-03f, 1.731756000e-02f, 1.633639200e-02f, 1.661124000e-02f, 1.610200800e-02f, 1.518132000e-02f, 1.543696800e-02f, 1.494840800e-02f, 1.408615200e-02f, 1.432362400e-02f, 6.302508000e-03f, 5.877588000e-03f, 5.978436000e-03f, 5.674380000e-03f, 5.280852000e-03f, 5.372100000e-03f, 5.080300000e-03f, 4.717140000e-03f, 4.799300000e-03f, 1.012140000e-03f, 8.963400000e-04f, 9.157800000e-04f, 7.925880000e-04f, 6.958920000e-04f, 7.118760000e-04f, 6.070840000e-04f, 5.284680000e-04f, 5.415080000e-04f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 6.154911480e-01f, 5.972259720e-01f, 6.050949480e-01f, 6.084786360e-01f, 5.904069000e-01f, 5.981864040e-01f, 6.015063160e-01f, 5.836269960e-01f, 5.913175400e-01f, 5.339936760e-01f, 5.179821960e-01f, 5.248113000e-01f, 5.274634680e-01f, 5.116331400e-01f, 5.183789160e-01f, 5.209734520e-01f, 5.053232520e-01f, 5.119862120e-01f, 1.168023864e+00f, 1.135450248e+00f, 1.149182760e+00f, 1.153890552e+00f, 1.121681544e+00f, 1.135247400e+00f, 1.139843768e+00f, 1.107997320e+00f, 1.121397544e+00f, 6.157732920e-01f, 5.993862600e-01f, 6.062159400e-01f, 6.082439160e-01f, 5.920403400e-01f, 5.987866920e-01f, 6.007608760e-01f, 5.847397320e-01f, 5.914032680e-01f, 1.332467832e+00f, 1.299143112e+00f, 1.312876776e+00f, 1.316336184e+00f, 1.283380680e+00f, 1.296947688e+00f, 1.300303352e+00f, 1.267715016e+00f, 1.281116392e+00f, 6.975529080e-01f, 6.807903240e-01f, 6.876205800e-01f, 6.890243640e-01f, 6.724475400e-01f, 6.791944680e-01f, 6.805483000e-01f, 6.641562120e-01f, 6.708203240e-01f, 5.986740600e-01f, 5.840730120e-01f, 5.899371240e-01f, 5.907752760e-01f, 5.763477000e-01f, 5.821346280e-01f, 5.829289720e-01f, 5.686738440e-01f, 5.743841000e-01f, 3.883616760e-01f, 3.764152200e-01f, 3.813857640e-01f, 3.827960760e-01f, 3.710061960e-01f, 3.759057000e-01f, 3.772706680e-01f, 3.656363400e-01f, 3.704653160e-01f, 3.242271480e-01f, 3.140920200e-01f, 3.182438760e-01f, 3.191438520e-01f, 3.091530120e-01f, 3.132399720e-01f, 3.141007480e-01f, 3.042531720e-01f, 3.082757480e-01f, 7.137372720e-01f, 6.929993040e-01f, 7.013773200e-01f, 7.027189680e-01f, 6.822718800e-01f, 6.905201040e-01f, 6.917871920e-01f, 6.716289360e-01f, 6.797483920e-01f, 3.739074360e-01f, 3.634797000e-01f, 3.676321320e-01f, 3.680461560e-01f, 3.577650120e-01f, 3.618525480e-01f, 3.622312120e-01f, 3.520956360e-01f, 3.561187880e-01f, 8.139825840e-01f, 7.926594000e-01f, 8.010385680e-01f, 8.014083120e-01f, 7.803806160e-01f, 7.886299920e-01f, 7.889328560e-01f, 7.681986000e-01f, 7.763192080e-01f, 4.235877240e-01f, 4.128673800e-01f, 4.170203880e-01f, 4.169484600e-01f, 4.063770120e-01f, 4.104651240e-01f, 4.103616760e-01f, 3.999381000e-01f, 4.039618280e-01f, 3.473802360e-01f, 3.383790600e-01f, 3.417871080e-01f, 3.413707320e-01f, 3.325061640e-01f, 3.358554600e-01f, 3.354137080e-01f, 3.266847240e-01f, 3.299757800e-01f, 1.111558776e+00f, 1.085129160e+00f, 1.095735528e+00f, 1.097208888e+00f, 1.071099336e+00f, 1.081563624e+00f, 1.082957816e+00f, 1.057166280e+00f, 1.067489512e+00f, 9.458819760e-01f, 9.231579600e-01f, 9.321269520e-01f, 9.327178800e-01f, 9.102893520e-01f, 9.191285520e-01f, 9.196526000e-01f, 8.975175120e-01f, 9.062279440e-01f, 2.032946736e+00f, 1.986563280e+00f, 2.004649872e+00f, 2.004915120e+00f, 1.959127248e+00f, 1.976954256e+00f, 1.977093424e+00f, 1.931897040e+00f, 1.949466512e+00f, 1.053205176e+00f, 1.029895944e+00f, 1.038866088e+00f, 1.038485112e+00f, 1.015475976e+00f, 1.024316328e+00f, 1.023876152e+00f, 1.001165064e+00f, 1.009876648e+00f, 2.249362608e+00f, 2.201808720e+00f, 2.219897616e+00f, 2.218219056e+00f, 2.171269968e+00f, 2.189099280e+00f, 2.187310000e+00f, 2.140961616e+00f, 2.158533392e+00f, 1.160528376e+00f, 1.136633928e+00f, 1.145605224e+00f, 1.144252344e+00f, 1.120662600e+00f, 1.129504104e+00f, 1.128099704e+00f, 1.104812616e+00f, 1.113525352e+00f, 9.733598640e-01f, 9.529866960e-01f, 9.604680720e-01f, 9.585645360e-01f, 9.384714960e-01f, 9.458353680e-01f, 9.438926000e-01f, 9.240776400e-01f, 9.313250320e-01f, 6.572168880e-01f, 6.410193360e-01f, 6.471559440e-01f, 6.464243760e-01f, 6.304731600e-01f, 6.365045520e-01f, 6.357306800e-01f, 6.200237520e-01f, 6.259509520e-01f, 5.342286000e-01f, 5.208519120e-01f, 5.257935120e-01f, 5.246218800e-01f, 5.114669520e-01f, 5.163156240e-01f, 5.151139760e-01f, 5.021787600e-01f, 5.069355280e-01f, 1.156058160e+00f, 1.128535248e+00f, 1.138567056e+00f, 1.135583664e+00f, 1.108508880e+00f, 1.118354832e+00f, 1.115319088e+00f, 1.088688336e+00f, 1.098350480e+00f, 5.932783920e-01f, 5.794823760e-01f, 5.844251280e-01f, 5.825580720e-01f, 5.689884240e-01f, 5.738382480e-01f, 5.719488560e-01f, 5.586035280e-01f, 5.633614480e-01f, 1.275927216e+00f, 1.247565648e+00f, 1.257599760e+00f, 1.253225520e+00f, 1.225321296e+00f, 1.235169552e+00f, 1.230758320e+00f, 1.203307344e+00f, 1.212971792e+00f, 6.523281840e-01f, 6.381128400e-01f, 6.430567440e-01f, 6.404942640e-01f, 6.265098960e-01f, 6.313608720e-01f, 6.287837360e-01f, 6.150282960e-01f, 6.197873680e-01f, 5.184650160e-01f, 5.068862160e-01f, 5.107825680e-01f, 5.081118000e-01f, 4.967394000e-01f, 5.005551120e-01f, 4.978819760e-01f, 4.867139280e-01f, 4.904500240e-01f, 3.309405360e-01f, 3.223208400e-01f, 3.253147920e-01f, 3.237054000e-01f, 3.152583120e-01f, 3.181839120e-01f, 3.165690800e-01f, 3.082925520e-01f, 3.111508240e-01f, 2.506407600e-01f, 2.439571920e-01f, 2.461985040e-01f, 2.445914160e-01f, 2.380558800e-01f, 2.402411280e-01f, 2.386408880e-01f, 2.322513360e-01f, 2.343815440e-01f, 5.512259040e-01f, 5.372551200e-01f, 5.418863520e-01f, 5.383085280e-01f, 5.246384160e-01f, 5.291575200e-01f, 5.256010720e-01f, 5.122275360e-01f, 5.166365600e-01f, 2.773423920e-01f, 2.704053840e-01f, 2.726478480e-01f, 2.706218160e-01f, 2.638374480e-01f, 2.660238480e-01f, 2.640123440e-01f, 2.573785680e-01f, 2.595099280e-01f, 6.063986400e-01f, 5.919209760e-01f, 5.965545120e-01f, 5.921388000e-01f, 5.779710240e-01f, 5.824924320e-01f, 5.781134560e-01f, 5.642514720e-01f, 5.686628000e-01f, 3.040440240e-01f, 2.968535760e-01f, 2.990971920e-01f, 2.966522160e-01f, 2.896190160e-01f, 2.918065680e-01f, 2.893838000e-01f, 2.825058000e-01f, 2.846383120e-01f, 2.234862000e-01f, 2.180475600e-01f, 2.196859920e-01f, 2.175750960e-01f, 2.122691280e-01f, 2.138637840e-01f, 2.117873840e-01f, 2.066120400e-01f, 2.081639440e-01f, 1.319976120e-01f, 1.282441800e-01f, 1.294102440e-01f, 1.280978040e-01f, 1.244341320e-01f, 1.255660200e-01f, 1.242566200e-01f, 1.206816840e-01f, 1.217799080e-01f, 8.906910000e-02f, 8.632520400e-02f, 8.711494800e-02f, 8.587278000e-02f, 8.320635600e-02f, 8.396806800e-02f, 8.273508400e-02f, 8.014510800e-02f, 8.087930000e-02f, 2.004561840e-01f, 1.946665680e-01f, 1.963203600e-01f, 1.936542000e-01f, 1.880218320e-01f, 1.896195600e-01f, 1.869756080e-01f, 1.814984400e-01f, 1.830411280e-01f, 9.843860400e-02f, 9.556798800e-02f, 9.635830800e-02f, 9.490666800e-02f, 9.211582800e-02f, 9.287811600e-02f, 9.143950000e-02f, 8.872741200e-02f, 8.946218000e-02f, 2.200799280e-01f, 2.140368720e-01f, 2.156918160e-01f, 2.126067120e-01f, 2.067255120e-01f, 2.083243920e-01f, 2.052691760e-01f, 1.995477840e-01f, 2.010916240e-01f, 1.078081080e-01f, 1.048107720e-01f, 1.056016680e-01f, 1.039405560e-01f, 1.010253000e-01f, 1.017881640e-01f, 1.001439160e-01f, 9.730971600e-02f, 9.804506000e-02f, 6.607767600e-02f, 6.399771600e-02f, 6.448602000e-02f, 6.306106800e-02f, 6.105090000e-02f, 6.151731600e-02f, 6.011537200e-02f, 5.817397200e-02f, 5.861901200e-02f, 2.853764400e-02f, 2.737045200e-02f, 2.762874000e-02f, 2.674830000e-02f, 2.563400400e-02f, 2.587654800e-02f, 2.501758000e-02f, 2.395515600e-02f, 2.418246800e-02f, 1.093470000e-02f, 1.033467600e-02f, 1.043782800e-02f, 9.848844000e-03f, 9.289428000e-03f, 9.382980000e-03f, 8.821612000e-03f, 8.301780000e-03f, 8.386244000e-03f, 3.332172000e-02f, 3.190279200e-02f, 3.218340000e-02f, 3.096184800e-02f, 2.962644000e-02f, 2.988784800e-02f, 2.872536800e-02f, 2.747143200e-02f, 2.771466400e-02f, 1.209274800e-02f, 1.144894800e-02f, 1.155267600e-02f, 1.089246000e-02f, 1.029157200e-02f, 1.038570000e-02f, 9.756940000e-03f, 9.197940000e-03f, 9.282980000e-03f, 3.652255200e-02f, 3.501607200e-02f, 3.529783200e-02f, 3.393381600e-02f, 3.251546400e-02f, 3.277802400e-02f, 3.148076000e-02f, 3.014848800e-02f, 3.039287200e-02f, 1.325079600e-02f, 1.256322000e-02f, 1.266752400e-02f, 1.193607600e-02f, 1.129371600e-02f, 1.138842000e-02f, 1.069226800e-02f, 1.009410000e-02f, 1.017971600e-02f, 2.154348000e-03f, 1.941780000e-03f, 1.964676000e-03f, 1.690572000e-03f, 1.510932000e-03f, 1.530372000e-03f, 1.297708000e-03f, 1.149972000e-03f, 1.166468000e-03f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 1.180984332e+00f, 1.160299956e+00f, 1.168172388e+00f, 1.167534444e+00f, 1.147057332e+00f, 1.154840292e+00f, 1.154161612e+00f, 1.133890740e+00f, 1.141584740e+00f, 1.024671372e+00f, 1.006406580e+00f, 1.013239140e+00f, 1.012146156e+00f, 9.940763400e-01f, 1.000825572e+00f, 9.996979960e-01f, 9.818221320e-01f, 9.884885480e-01f, 2.154687672e+00f, 2.117607432e+00f, 2.131346856e+00f, 2.128564344e+00f, 2.091876360e+00f, 2.105449128e+00f, 2.102601272e+00f, 2.066303496e+00f, 2.079710632e+00f, 1.106450988e+00f, 1.087810644e+00f, 1.094643780e+00f, 1.092926604e+00f, 1.074483540e+00f, 1.081233348e+00f, 1.079485420e+00f, 1.061238612e+00f, 1.067905604e+00f, 2.319131640e+00f, 2.281300296e+00f, 2.295040872e+00f, 2.291009976e+00f, 2.253575496e+00f, 2.267149416e+00f, 2.263060856e+00f, 2.226021192e+00f, 2.239429480e+00f, 1.188230604e+00f, 1.169214708e+00f, 1.176048420e+00f, 1.173707052e+00f, 1.154890740e+00f, 1.161641124e+00f, 1.159272844e+00f, 1.140655092e+00f, 1.147322660e+00f, 1.019844684e+00f, 1.003156212e+00f, 1.009023780e+00f, 1.006393260e+00f, 9.898920840e-01f, 9.956824680e-01f, 9.930311800e-01f, 9.767162760e-01f, 9.824299880e-01f, 7.453336440e-01f, 7.314656520e-01f, 7.364396520e-01f, 7.346577720e-01f, 7.209601800e-01f, 7.258631400e-01f, 7.240589560e-01f, 7.105307400e-01f, 7.153631720e-01f, 6.223088760e-01f, 6.104181000e-01f, 6.145734120e-01f, 6.125576760e-01f, 6.008250120e-01f, 6.049154280e-01f, 6.028835320e-01f, 5.913079560e-01f, 5.953339880e-01f, 1.315209144e+00f, 1.290959880e+00f, 1.299344808e+00f, 1.294855032e+00f, 1.270924296e+00f, 1.279179432e+00f, 1.274661176e+00f, 1.251046920e+00f, 1.259173288e+00f, 6.719891640e-01f, 6.598057800e-01f, 6.639616680e-01f, 6.614599800e-01f, 6.494370120e-01f, 6.535280040e-01f, 6.510139960e-01f, 6.391504200e-01f, 6.431770280e-01f, 1.415454456e+00f, 1.390619976e+00f, 1.399006056e+00f, 1.393544376e+00f, 1.369033032e+00f, 1.377289320e+00f, 1.371806840e+00f, 1.347616584e+00f, 1.355744104e+00f, 7.216694520e-01f, 7.091934600e-01f, 7.133499240e-01f, 7.103622840e-01f, 6.980490120e-01f, 7.021405800e-01f, 6.991444600e-01f, 6.869928840e-01f, 6.910200680e-01f, 5.918801400e-01f, 5.812892040e-01f, 5.847007080e-01f, 5.816451000e-01f, 5.712045960e-01f, 5.745573480e-01f, 5.714994040e-01f, 5.612083080e-01f, 5.645028200e-01f, 1.873278456e+00f, 1.843005768e+00f, 1.853619048e+00f, 1.848708024e+00f, 1.818783048e+00f, 1.829254248e+00f, 1.824310136e+00f, 1.794730824e+00f, 1.805060968e+00f, 1.589821176e+00f, 1.563585864e+00f, 1.572561768e+00f, 1.567321272e+00f, 1.541409096e+00f, 1.550255208e+00f, 1.544993912e+00f, 1.519402824e+00f, 1.528120168e+00f, 3.331441968e+00f, 3.278035920e+00f, 3.296136336e+00f, 3.284738736e+00f, 3.231983568e+00f, 3.249824400e+00f, 3.238392880e+00f, 3.186284496e+00f, 3.203867792e+00f, 1.697144376e+00f, 1.670323848e+00f, 1.679300904e+00f, 1.673088504e+00f, 1.646595720e+00f, 1.655442984e+00f, 1.649217464e+00f, 1.623050376e+00f, 1.631768872e+00f, 3.547857840e+00f, 3.493281360e+00f, 3.511384080e+00f, 3.498042672e+00f, 3.444126288e+00f, 3.461969424e+00f, 3.448609456e+00f, 3.395349072e+00f, 3.412934672e+00f, 1.804467576e+00f, 1.777061832e+00f, 1.786040040e+00f, 1.778855736e+00f, 1.751782344e+00f, 1.760630760e+00f, 1.753441016e+00f, 1.726697928e+00f, 1.735417576e+00f, 1.510135416e+00f, 1.486582728e+00f, 1.494071016e+00f, 1.486889016e+00f, 1.463644104e+00f, 1.471014888e+00f, 1.463839736e+00f, 1.440900552e+00f, 1.448154856e+00f, 1.097445624e+00f, 1.078400328e+00f, 1.084543848e+00f, 1.079086776e+00f, 1.060315464e+00f, 1.066353768e+00f, 1.060900472e+00f, 1.042401096e+00f, 1.048335208e+00f, 8.885273520e-01f, 8.726346960e-01f, 8.775832080e-01f, 8.722390320e-01f, 8.565957840e-01f, 8.614513680e-01f, 8.561232560e-01f, 8.407273680e-01f, 8.454910480e-01f, 1.875272496e+00f, 1.842717648e+00f, 1.852763280e+00f, 1.841434800e+00f, 1.809383376e+00f, 1.819243152e+00f, 1.807954480e+00f, 1.776402384e+00f, 1.786078352e+00f, 9.475771440e-01f, 9.312651600e-01f, 9.362148240e-01f, 9.301752240e-01f, 9.141172560e-01f, 9.189739920e-01f, 9.129581360e-01f, 8.971521360e-01f, 9.019169680e-01f, 1.995141552e+00f, 1.961748048e+00f, 1.971795984e+00f, 1.959076656e+00f, 1.926195792e+00f, 1.936057872e+00f, 1.923393712e+00f, 1.891021392e+00f, 1.900699664e+00f, 1.006626936e+00f, 9.898956240e-01f, 9.948464400e-01f, 9.881114160e-01f, 9.716387280e-01f, 9.764966160e-01f, 9.697930160e-01f, 9.535769040e-01f, 9.583428880e-01f, 7.974506160e-01f, 7.836876240e-01f, 7.875908880e-01f, 7.813005360e-01f, 7.677715920e-01f, 7.715942160e-01f, 7.653475760e-01f, 7.520506320e-01f, 7.557936400e-01f, 5.452298160e-01f, 5.347577040e-01f, 5.377585680e-01f, 5.330825520e-01f, 5.228106960e-01f, 5.257432080e-01f, 5.211078320e-01f, 5.110341840e-01f, 5.138993680e-01f, 4.108505520e-01f, 4.026463440e-01f, 4.048945680e-01f, 4.007738160e-01f, 3.927452880e-01f, 3.949374480e-01f, 3.908696240e-01f, 3.830147280e-01f, 3.851518480e-01f, 8.822623200e-01f, 8.652502560e-01f, 8.698953120e-01f, 8.612901600e-01f, 8.446340640e-01f, 8.491669920e-01f, 8.406753760e-01f, 8.243711520e-01f, 8.287940000e-01f, 4.375521840e-01f, 4.290945360e-01f, 4.313439120e-01f, 4.268042160e-01f, 4.185268560e-01f, 4.207201680e-01f, 4.162410800e-01f, 4.081419600e-01f, 4.102802320e-01f, 9.374350560e-01f, 9.199161120e-01f, 9.245634720e-01f, 9.151204320e-01f, 8.979666720e-01f, 9.025019040e-01f, 8.931877600e-01f, 8.763950880e-01f, 8.808202400e-01f, 4.642538160e-01f, 4.555427280e-01f, 4.577932560e-01f, 4.528346160e-01f, 4.443084240e-01f, 4.465028880e-01f, 4.416125360e-01f, 4.332691920e-01f, 4.354086160e-01f, 3.402333360e-01f, 3.336058320e-01f, 3.352511760e-01f, 3.311795760e-01f, 3.247123920e-01f, 3.263139600e-01f, 3.223229360e-01f, 3.160140240e-01f, 3.175728400e-01f, 2.152543800e-01f, 2.105747400e-01f, 2.117442600e-01f, 2.088985080e-01f, 2.043224520e-01f, 2.054577960e-01f, 2.026381240e-01f, 1.981646280e-01f, 1.992663080e-01f, 1.452861240e-01f, 1.417819080e-01f, 1.425751080e-01f, 1.400761080e-01f, 1.366631880e-01f, 1.374283560e-01f, 1.349615800e-01f, 1.316389320e-01f, 1.323765800e-01f, 3.181986480e-01f, 3.108883920e-01f, 3.125490960e-01f, 3.073692720e-01f, 3.002439120e-01f, 3.018485520e-01f, 2.967370160e-01f, 2.897945040e-01f, 2.913441040e-01f, 1.546556280e-01f, 1.510246920e-01f, 1.518184680e-01f, 1.491099960e-01f, 1.455726600e-01f, 1.463384040e-01f, 1.436659960e-01f, 1.402212360e-01f, 1.409594600e-01f, 3.378223920e-01f, 3.302586960e-01f, 3.319205520e-01f, 3.263217840e-01f, 3.189475920e-01f, 3.205533840e-01f, 3.150305840e-01f, 3.078438480e-01f, 3.093946000e-01f, 1.640251320e-01f, 1.602674760e-01f, 1.610618280e-01f, 1.581438840e-01f, 1.544821320e-01f, 1.552484520e-01f, 1.523704120e-01f, 1.488035400e-01f, 1.495423400e-01f, 1.005633720e-01f, 9.788898000e-02f, 9.838074000e-02f, 9.597543600e-02f, 9.338466000e-02f, 9.385453200e-02f, 9.149527600e-02f, 8.898709200e-02f, 8.943558800e-02f, 4.660042800e-02f, 4.500469200e-02f, 4.526643600e-02f, 4.368212400e-02f, 4.215310800e-02f, 4.239910800e-02f, 4.085930800e-02f, 3.939598800e-02f, 3.962675600e-02f, 1.788298800e-02f, 1.702030800e-02f, 1.712691600e-02f, 1.611054000e-02f, 1.530229200e-02f, 1.539930000e-02f, 1.443358000e-02f, 1.367874000e-02f, 1.376666000e-02f, 5.252671200e-02f, 5.058247200e-02f, 5.086999200e-02f, 4.879365600e-02f, 4.696058400e-02f, 4.722890400e-02f, 4.525772000e-02f, 4.353376800e-02f, 4.378391200e-02f, 1.904103600e-02f, 1.813458000e-02f, 1.824176400e-02f, 1.715415600e-02f, 1.630443600e-02f, 1.640202000e-02f, 1.536890800e-02f, 1.457490000e-02f, 1.466339600e-02f, 5.572754400e-02f, 5.369575200e-02f, 5.398442400e-02f, 5.176562400e-02f, 4.984960800e-02f, 5.011908000e-02f, 4.801311200e-02f, 4.621082400e-02f, 4.646212000e-02f, 2.019908400e-02f, 1.924885200e-02f, 1.935661200e-02f, 1.819777200e-02f, 1.730658000e-02f, 1.740474000e-02f, 1.630423600e-02f, 1.547106000e-02f, 1.556013200e-02f, 3.296556000e-03f, 2.987220000e-03f, 3.013572000e-03f, 2.588556000e-03f, 2.325972000e-03f, 2.348868000e-03f, 1.988332000e-03f, 1.771476000e-03f, 1.791428000e-03f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, }; float[] x_actual = x.ToArray(); AssertError.Tolerance(x_expect, x_actual, 1e-7f, 1e-5f, $"mismatch value {inchannels},{outchannels},{kwidth},{kheight},{stride},{inwidth},{inheight},{batch}"); }
public void ReferenceTest() { int inchannels = 9, outchannels = 12, kwidth = 3, kheight = 5, stride = 2, inwidth = 7, inheight = 8, batch = 3; int outwidth = (inwidth - kwidth) / stride + 1, outheight = (inheight - kheight) / stride + 1; float[] xval = (new float[batch * inwidth * inheight * inchannels]).Select((_, idx) => idx * 1e-3f).ToArray(); float[] wval = (new float[kwidth * kheight * outchannels * inchannels / 9 * 4]).Select((_, idx) => idx * 1e-3f).Reverse().ToArray(); Trivector[] xcval = (new Trivector[xval.Length / 3]) .Select((_, idx) => new Trivector(xval[idx * 3], xval[idx * 3 + 1], xval[idx * 3 + 2])).ToArray(); Quaternion.Quaternion[] wcval = (new Quaternion.Quaternion[wval.Length / 4]) .Select((_, idx) => new Quaternion.Quaternion(wval[idx * 4], wval[idx * 4 + 1], wval[idx * 4 + 2], wval[idx * 4 + 3])).ToArray(); TrivectorMap2D x = new TrivectorMap2D(inchannels / 3, inwidth, inheight, batch, xcval); Quaternion.QuaternionFilter2D w = new Quaternion.QuaternionFilter2D(inchannels / 3, outchannels / 3, kwidth, kheight, wcval); TrivectorMap2D y = Reference(x, w, kwidth, kheight, stride); float[] y_expect = { 2.181353820e+00f, 2.096150130e+00f, 2.129823480e+00f, 2.035735260e+00f, 1.954642050e+00f, 1.986704040e+00f, 1.897374300e+00f, 1.820287890e+00f, 1.850790360e+00f, 1.766270940e+00f, 1.693087650e+00f, 1.722082440e+00f, 2.784901560e+00f, 2.696023710e+00f, 2.729706780e+00f, 2.610317400e+00f, 2.525666670e+00f, 2.557738380e+00f, 2.443923960e+00f, 2.363396670e+00f, 2.393908860e+00f, 2.285721240e+00f, 2.209213710e+00f, 2.238218220e+00f, 3.388449300e+00f, 3.295897290e+00f, 3.329590080e+00f, 3.184899540e+00f, 3.096691290e+00f, 3.128772720e+00f, 2.990473620e+00f, 2.906505450e+00f, 2.937027360e+00f, 2.805171540e+00f, 2.725339770e+00f, 2.754354000e+00f, 6.406188000e+00f, 6.295265190e+00f, 6.329006580e+00f, 6.057810240e+00f, 5.951814390e+00f, 5.983944420e+00f, 5.723221920e+00f, 5.622049350e+00f, 5.652619860e+00f, 5.402423040e+00f, 5.305970070e+00f, 5.335032900e+00f, 7.009735740e+00f, 6.895138770e+00f, 6.928889880e+00f, 6.632392380e+00f, 6.522839010e+00f, 6.554978760e+00f, 6.269771580e+00f, 6.165158130e+00f, 6.195738360e+00f, 5.921873340e+00f, 5.822096130e+00f, 5.851168680e+00f, 7.613283480e+00f, 7.495012350e+00f, 7.528773180e+00f, 7.206974520e+00f, 7.093863630e+00f, 7.126013100e+00f, 6.816321240e+00f, 6.708266910e+00f, 6.738856860e+00f, 6.441323640e+00f, 6.338222190e+00f, 6.367304460e+00f, 1.908069054e+01f, 1.889261037e+01f, 1.892655588e+01f, 1.812403518e+01f, 1.794333141e+01f, 1.797566556e+01f, 1.720076478e+01f, 1.702733373e+01f, 1.705810836e+01f, 1.631087934e+01f, 1.614461733e+01f, 1.617388428e+01f, 1.968423828e+01f, 1.949248395e+01f, 1.952643918e+01f, 1.869861732e+01f, 1.851435603e+01f, 1.854669990e+01f, 1.774731444e+01f, 1.757044251e+01f, 1.760122686e+01f, 1.683032964e+01f, 1.666074339e+01f, 1.669002006e+01f, 2.028778602e+01f, 2.009235753e+01f, 2.012632248e+01f, 1.927319946e+01f, 1.908538065e+01f, 1.911773424e+01f, 1.829386410e+01f, 1.811355129e+01f, 1.814434536e+01f, 1.734977994e+01f, 1.717686945e+01f, 1.720615584e+01f, 2.330552472e+01f, 2.309172543e+01f, 2.312573898e+01f, 2.214611016e+01f, 2.194050375e+01f, 2.197290594e+01f, 2.102661240e+01f, 2.082909519e+01f, 2.085993786e+01f, 1.994703144e+01f, 1.975749975e+01f, 1.978683474e+01f, 2.390907246e+01f, 2.369159901e+01f, 2.372562228e+01f, 2.272069230e+01f, 2.251152837e+01f, 2.254394028e+01f, 2.157316206e+01f, 2.137220397e+01f, 2.140305636e+01f, 2.046648174e+01f, 2.027362581e+01f, 2.030297052e+01f, 2.451262020e+01f, 2.429147259e+01f, 2.432550558e+01f, 2.329527444e+01f, 2.308255299e+01f, 2.311497462e+01f, 2.211971172e+01f, 2.191531275e+01f, 2.194617486e+01f, 2.098593204e+01f, 2.078975187e+01f, 2.081910630e+01f, 3.598002726e+01f, 3.568907061e+01f, 3.572328828e+01f, 3.421233510e+01f, 3.393202077e+01f, 3.396462708e+01f, 3.250415526e+01f, 3.223437957e+01f, 3.226542636e+01f, 3.085548774e+01f, 3.059614701e+01f, 3.062568612e+01f, 3.658357500e+01f, 3.628894419e+01f, 3.632317158e+01f, 3.478691724e+01f, 3.450304539e+01f, 3.453566142e+01f, 3.305070492e+01f, 3.277748835e+01f, 3.280854486e+01f, 3.137493804e+01f, 3.111227307e+01f, 3.114182190e+01f, 3.718712274e+01f, 3.688881777e+01f, 3.692305488e+01f, 3.536149938e+01f, 3.507407001e+01f, 3.510669576e+01f, 3.359725458e+01f, 3.332059713e+01f, 3.335166336e+01f, 3.189438834e+01f, 3.162839913e+01f, 3.165795768e+01f, 4.020486144e+01f, 3.988818567e+01f, 3.992247138e+01f, 3.823441008e+01f, 3.792919311e+01f, 3.796186746e+01f, 3.633000288e+01f, 3.603614103e+01f, 3.606725586e+01f, 3.449163984e+01f, 3.420902943e+01f, 3.423863658e+01f, 4.080840918e+01f, 4.048805925e+01f, 4.052235468e+01f, 3.880899222e+01f, 3.850021773e+01f, 3.853290180e+01f, 3.687655254e+01f, 3.657924981e+01f, 3.661037436e+01f, 3.501109014e+01f, 3.472515549e+01f, 3.475477236e+01f, 4.141195692e+01f, 4.108793283e+01f, 4.112223798e+01f, 3.938357436e+01f, 3.907124235e+01f, 3.910393614e+01f, 3.742310220e+01f, 3.712235859e+01f, 3.715349286e+01f, 3.553054044e+01f, 3.524128155e+01f, 3.527090814e+01f, }; float[] y_actual = y.ToArray(); AssertError.Tolerance(y_expect, y_actual, 1e-7f, 1e-5f, $"mismatch value {inchannels},{outchannels},{kwidth},{kheight},{stride},{inwidth},{inheight},{batch}"); }