Ejemplo n.º 1
0
        public void Dist2Test(string mode, string test, Dictionary <string, string> environmentVariables)
        {
            RemoteExecutor.RemoteInvoke((arg0, arg1) =>
            {
                CheckProperFlag(arg0);
                float[] src = (float[])_testArrays[int.Parse(arg1)].Clone();
                float[] dst = (float[])src.Clone();

                // Ensures src and dst are different arrays
                for (int i = 0; i < dst.Length; i++)
                {
                    dst[i] += 1;
                }

                float expected = 0;
                for (int i = 0; i < dst.Length; i++)
                {
                    float distance = src[i] - dst[i];
                    expected      += distance * distance;
                }

                var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length);
                Assert.Equal(expected, actual, 0);
                return(RemoteExecutor.SuccessExitCode);
            }, mode, test, new RemoteInvokeOptions(environmentVariables));
        }
Ejemplo n.º 2
0
        private static Float L2DiffSquaredDense(Float[] valuesA, Float[] valuesB, int length)
        {
            Contracts.AssertValueOrNull(valuesA);
            Contracts.AssertValueOrNull(valuesB);
            Contracts.Assert(0 <= length && length <= Utils.Size(valuesA));
            Contracts.Assert(0 <= length && length <= Utils.Size(valuesB));

            if (length == 0)
            {
                return(0);
            }
            return(CpuMathUtils.L2DistSquared(valuesA, valuesB, length));
        }
Ejemplo n.º 3
0
        public void Dist2Test(int test, float expected)
        {
            float[] src = (float[])testArrays[test].Clone();
            float[] dst = (float[])src.Clone();

            // Ensures src and dst are different arrays
            for (int i = 0; i < dst.Length; i++)
            {
                dst[i] += 1;
            }

            var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length);

            Assert.Equal(expected, actual, 0);
        }
Ejemplo n.º 4
0
 public float Dist2()
 => CpuMathUtils.L2DistSquared(src, dst, _smallInputLength);
Ejemplo n.º 5
0
 public float ManagedDist2Perf() => CpuMathUtils.L2DistSquared(src, dst, LEN);