コード例 #1
0
        public void MulElementWiseUTest(string mode, string test, Dictionary <string, string> environmentVariables)
        {
            RemoteExecutor.RemoteInvoke((arg0, arg1) =>
            {
                CheckProperFlag(arg1);
                float[] src1 = (float[])_testArrays[int.Parse(arg1)].Clone();
                float[] src2 = (float[])src1.Clone();
                float[] dst  = (float[])src1.Clone();

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

                float[] expected = (float[])src1.Clone();

                for (int i = 0; i < expected.Length; i++)
                {
                    expected[i] *= (1 + expected[i]);
                }

                CpuMathUtils.MulElementWise(src1, src2, dst, dst.Length);
                var actual = dst;
                Assert.Equal(expected, actual, _comparer);
                return(RemoteExecutor.SuccessExitCode);
            }, mode, test, new RemoteInvokeOptions(environmentVariables));
        }
コード例 #2
0
        /// <summary>
        /// Multiplies arrays Dst *= A element by element and returns the result in <paramref name="dst"/> (Hadamard product).
        /// </summary>
        public static void MulElementWise(ref VBuffer <Float> a, ref VBuffer <Float> dst)
        {
            Contracts.Check(a.Length == dst.Length, "Vectors must have the same dimensionality.");

            if (a.IsDense && dst.IsDense)
            {
                CpuMathUtils.MulElementWise(a.Values, dst.Values, dst.Values, a.Length);
            }
            else
            {
                VBufferUtils.ApplyWithEitherDefined(ref a, ref dst, (int ind, Float v1, ref Float v2) => { v2 *= v1; });
            }
        }
コード例 #3
0
        public void MulElementWiseUTest(int test)
        {
            float[] src1 = (float[])testArrays[test].Clone();
            float[] src2 = (float[])src1.Clone();
            float[] dst  = (float[])src1.Clone();

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

            float[] expected = (float[])src1.Clone();

            for (int i = 0; i < expected.Length; i++)
            {
                expected[i] *= (1 + expected[i]);
            }

            CpuMathUtils.MulElementWise(src1, src2, dst, dst.Length);
            var actual = dst;

            Assert.Equal(expected, actual, comparer);
        }
コード例 #4
0
 public void MulElementWiseU()
 => CpuMathUtils.MulElementWise(src1, src2, dst, _smallInputLength);
コード例 #5
0
 public void ManagedMulElementWiseUPerf() => CpuMathUtils.MulElementWise(src1, src2, dst, LEN);