public CpuMathUtilsUnitTests()
        {
            // Padded array whose length is a multiple of 4
            float[] testArray1 = new float[16] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f
            };
            // Unpadded array whose length is not a multiple of 4.
            float[] testArray2 = new float[15] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f
            };
            _testArrays     = new float[][] { testArray1, testArray2 };
            _testIndexArray = new int[9] {
                0, 2, 5, 6, 8, 11, 12, 13, 14
            };
            _comparer       = new FloatEqualityComparer();
            _matMulComparer = new FloatEqualityComparerForMatMul();

            // Padded matrices whose dimensions are multiples of 8
            float[] testMatrix1 = new float[8 * 8] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f
            };
            float[] testMatrix2 = new float[8 * 16];

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

            _testMatrices = new float[][] { testMatrix1, testMatrix2 };

            // Padded source vectors whose dimensions are multiples of 8
            float[] testSrcVector1 = new float[8] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f
            };
            float[] testSrcVector2 = new float[16] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f
            };

            _testSrcVectors = new float[][] { testSrcVector1, testSrcVector2 };

            // Padded destination vectors whose dimensions are multiples of 8
            float[] testDstVector1 = new float[8] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f
            };
            float[] testDstVector2 = new float[16] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f
            };

            _testDstVectors = new float[][] { testDstVector1, testDstVector2 };
        }
示例#2
0
        static CpuMathUtilsUnitTests()
        {
            // Padded array whose length is a multiple of 4
            float[] testArray1 = new float[16] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f
            };
            // Unpadded array whose length is not a multiple of 4.
            float[] testArray2 = new float[15] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f
            };
            _testArrays     = new float[][] { testArray1, testArray2 };
            _testIndexArray = new int[9] {
                0, 2, 5, 6, 8, 11, 12, 13, 14
            };
            _comparer       = new FloatEqualityComparer();
            _matMulComparer = new FloatEqualityComparerForMatMul();

            // Padded matrices whose dimensions are multiples of 8
            float[] testMatrix1 = new float[8 * 8] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f
            };
            float[] testMatrix2 = new float[8 * 16];

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

            AlignedArray testMatrixAligned1 = new AlignedArray(8 * 8, _vectorAlignment);
            AlignedArray testMatrixAligned2 = new AlignedArray(8 * 16, _vectorAlignment);

            testMatrixAligned1.CopyFrom(testMatrix1);
            testMatrixAligned2.CopyFrom(testMatrix2);

            _testMatrices = new AlignedArray[] { testMatrixAligned1, testMatrixAligned2 };

            // Padded source vectors whose dimensions are multiples of 8
            float[] testSrcVector1 = new float[8] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f
            };
            float[] testSrcVector2 = new float[16] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f
            };

            AlignedArray testSrcVectorAligned1 = new AlignedArray(8, _vectorAlignment);
            AlignedArray testSrcVectorAligned2 = new AlignedArray(16, _vectorAlignment);

            testSrcVectorAligned1.CopyFrom(testSrcVector1);
            testSrcVectorAligned2.CopyFrom(testSrcVector2);

            _testSrcVectors = new AlignedArray[] { testSrcVectorAligned1, testSrcVectorAligned2 };

            // Padded destination vectors whose dimensions are multiples of 8
            float[] testDstVector1 = new float[8] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f
            };
            float[] testDstVector2 = new float[16] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f
            };

            AlignedArray testDstVectorAligned1 = new AlignedArray(8, _vectorAlignment);
            AlignedArray testDstVectorAligned2 = new AlignedArray(16, _vectorAlignment);

            testDstVectorAligned1.CopyFrom(testDstVector1);
            testDstVectorAligned2.CopyFrom(testDstVector2);

            _testDstVectors = new AlignedArray[] { testDstVectorAligned1, testDstVectorAligned2 };

#if NETCOREAPP3_0
            DisableAvxEnvironmentVariables = new Dictionary <string, string>()
            {
                { disableAvx, "0" }
            };

            DisableAvxAndSseEnvironmentVariables = new Dictionary <string, string>()
            {
                { disableAvx, "0" },
                { disableSse, "0" }
            };
#endif
        }
示例#3
0
        static CpuMathUtilsUnitTests()
        {
            // Padded array whose length is a multiple of 4
            float[] testArray1 = new float[32] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f
            };
            // Unpadded array whose length is not a multiple of 4.
            float[] testArray2 = new float[30] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f
            };
            // Small Input Size Array
            float[] testArray3 = new float[15] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f, 1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f
            };
            _testArrays     = new float[][] { testArray1, testArray2, testArray3 };
            _testIndexArray = new int[18] {
                0, 2, 5, 6, 8, 11, 12, 13, 14, 16, 18, 21, 22, 24, 26, 27, 28, 29
            };
            _comparer       = new FloatEqualityComparer();
            _matMulComparer = new FloatEqualityComparerForMatMul();

            // Padded matrices whose dimensions are multiples of 8
            float[] testMatrix1 = new float[8 * 8] {
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f,
                1.96f, -2.38f, -9.76f, 13.84f, -106.37f, -26.93f, 32.45f, 3.29f
            };
            float[] testMatrix2 = new float[8 * 16];

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

            AlignedArray testMatrixAligned1 = new AlignedArray(8 * 8, _vectorAlignment);
            AlignedArray testMatrixAligned2 = new AlignedArray(8 * 16, _vectorAlignment);

            testMatrixAligned1.CopyFrom(testMatrix1);
            testMatrixAligned2.CopyFrom(testMatrix2);

            _testMatrices = new AlignedArray[] { testMatrixAligned1, testMatrixAligned2 };

            // Padded source vectors whose dimensions are multiples of 8
            float[] testSrcVector1 = new float[8] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f
            };
            float[] testSrcVector2 = new float[16] {
                1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f
            };

            AlignedArray testSrcVectorAligned1 = new AlignedArray(8, _vectorAlignment);
            AlignedArray testSrcVectorAligned2 = new AlignedArray(16, _vectorAlignment);

            testSrcVectorAligned1.CopyFrom(testSrcVector1);
            testSrcVectorAligned2.CopyFrom(testSrcVector2);

            _testSrcVectors = new AlignedArray[] { testSrcVectorAligned1, testSrcVectorAligned2 };

            // Padded destination vectors whose dimensions are multiples of 8
            float[] testDstVector1 = new float[8] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f
            };
            float[] testDstVector2 = new float[16] {
                0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f
            };

            AlignedArray testDstVectorAligned1 = new AlignedArray(8, _vectorAlignment);
            AlignedArray testDstVectorAligned2 = new AlignedArray(16, _vectorAlignment);

            testDstVectorAligned1.CopyFrom(testDstVector1);
            testDstVectorAligned2.CopyFrom(testDstVector2);

            _testDstVectors = new AlignedArray[] { testDstVectorAligned1, testDstVectorAligned2 };

            if ((SkipAvxSse || IsNetCore) && !IsNetCore2OrOlder)
            {
                _disableAvxEnvironmentVariables = new Dictionary <string, string>()
                {
                    { _disableAvx, "0" }
                };

                _disableAvxAndSseEnvironmentVariables = new Dictionary <string, string>()
                {
                    { _disableAvx, "0" },
                    { _disableSse, "0" }
                };
            }
        }