Example #1
0
                static void RunTest(string serialized)
                {
                    int seed = FeatureTestRunner.Deserialize <int>(serialized);

                    Span <float> src   = Create8x8RoundedRandomFloatData(MinAllowedValue, MaxAllowedValue, seed);
                    var          block = default(Block8x8F);

                    block.LoadFrom(src);

                    float[] expectedDest = new float[64];
                    float[] temp1        = new float[64];

                    // reference
                    ReferenceImplementations.LLM_FloatingPoint_DCT.FDCT2D_llm(src, expectedDest, temp1, downscaleBy8: true);

                    // testee
                    // Second transpose call is done by Quantize step
                    // Do this manually here just to be complient to the reference implementation
                    FastFloatingPointDCT.TransformFDCT(ref block);
                    block.TransposeInplace();

                    // Part of the IDCT calculations is fused into the quantization step
                    // We must multiply input block with adjusted no-quantization matrix
                    // after applying FDCT
                    Block8x8F quantMatrix = CreateBlockFromScalar(1);

                    FastFloatingPointDCT.AdjustToFDCT(ref quantMatrix);
                    block.MultiplyInPlace(ref quantMatrix);

                    float[] actualDest = block.ToArray();

                    Assert.Equal(expectedDest, actualDest, new ApproximateFloatComparer(1f));
                }
Example #2
0
                static void RunTest(string serialized)
                {
                    int seed = FeatureTestRunner.Deserialize <int>(serialized);

                    Span <float> src   = Create8x8RoundedRandomFloatData(-200, 200, seed);
                    var          block = default(Block8x8F);

                    block.LoadFrom(src);

                    float[] expectedDest = new float[64];
                    float[] temp1        = new float[64];

                    // reference
                    ReferenceImplementations.LLM_FloatingPoint_DCT.FDCT2D_llm(src, expectedDest, temp1, downscaleBy8: true);

                    // testee
                    // Part of the FDCT calculations is fused into the quantization step
                    // We must multiply transformed block with reciprocal values from FastFloatingPointDCT.ANN_DCT_reciprocalAdjustmen
                    FastFloatingPointDCT.TransformFDCT(ref block);
                    for (int i = 0; i < 64; i++)
                    {
                        block[i] = block[i] * FastFloatingPointDCT.DctReciprocalAdjustmentCoefficients[i];
                    }

                    float[] actualDest = block.ToArray();

                    Assert.Equal(expectedDest, actualDest, new ApproximateFloatComparer(1f));
                }
Example #3
0
                static void RunTest(string serialized)
                {
                    int seed = FeatureTestRunner.Deserialize <int>(serialized);

                    Span <float> src      = Create8x8RoundedRandomFloatData(-200, 200, seed);
                    var          srcBlock = default(Block8x8F);

                    srcBlock.LoadFrom(src);

                    var expectedDest = new float[64];
                    var temp1        = new float[64];
                    var temp2        = default(Block8x8F);

                    // reference
                    ReferenceImplementations.LLM_FloatingPoint_DCT.IDCT2D_llm(src, expectedDest, temp1);

                    // testee
                    FastFloatingPointDCT.TransformIDCT(ref srcBlock, ref temp2);

                    var actualDest = new float[64];

                    srcBlock.ScaledCopyTo(actualDest);

                    Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
                }
Example #4
0
        public void AllowsAllHwIntrinsicFeatures()
        {
            if (!Vector.IsHardwareAccelerated)
            {
                return;
            }

            FeatureTestRunner.RunWithHwIntrinsicsFeature(
                () => Assert.True(Vector.IsHardwareAccelerated),
                HwIntrinsics.AllowAll);
        }
            static void RunTest(string serialized)
            {
                // No need to test multiple shuffle controls as the
                // pipeline is always the same.
                int  size    = FeatureTestRunner.Deserialize <int>(serialized);
                byte control = default(WZYXShuffle4).Control;

                TestShuffleFloat4Channel(
                    size,
                    (s, d) => SimdUtils.Shuffle4Channel(s.Span, d.Span, control),
                    control);
            }
Example #6
0
            static void RunTest(string serialized)
            {
                TestImageProvider <Rgba32> provider =
                    FeatureTestRunner.DeserializeForXunit <TestImageProvider <Rgba32> >(serialized);

                foreach (PngInterlaceMode interlaceMode in InterlaceMode)
                {
                    TestPngEncoderCore(
                        provider,
                        PngColorType.Rgb,
                        PngFilterMethod.Adaptive,
                        PngBitDepth.Bit8,
                        interlaceMode,
                        appendPixelType: true,
                        appendPngColorType: true);
                }
            }
Example #7
0
                static void RunTest(string serialized)
                {
                    int seed = FeatureTestRunner.Deserialize <int>(serialized);

                    Span <float> src      = Create8x8RoundedRandomFloatData(MinAllowedValue, MaxAllowedValue, seed);
                    var          srcBlock = default(Block8x8F);

                    srcBlock.LoadFrom(src);

                    float[] expectedDest = new float[64];
                    float[] temp         = new float[64];

                    // reference
                    ReferenceImplementations.LLM_FloatingPoint_DCT.IDCT2D_llm(src, expectedDest, temp);

                    // testee
                    // Part of the IDCT calculations is fused into the quantization step
                    // We must multiply input block with adjusted no-quantization matrix
                    // before applying IDCT
                    Block8x8F dequantMatrix = CreateBlockFromScalar(1);

                    // Dequantization using unit matrix - no values are upscaled
                    // as quant matrix is all 1's
                    // This step is needed to apply adjusting multipliers to the input block
                    FastFloatingPointDCT.AdjustToIDCT(ref dequantMatrix);
                    srcBlock.MultiplyInPlace(ref dequantMatrix);

                    // IDCT implementation tranforms blocks after transposition
                    srcBlock.TransposeInplace();

                    // IDCT calculation
                    FastFloatingPointDCT.TransformIDCT(ref srcBlock);

                    float[] actualDest = srcBlock.ToArray();

                    Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
                }
Example #8
0
 public void TransformColorInverse_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableAVX2);
Example #9
0
 public void TransformColor_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableSSE2);
Example #10
0
 public void TransformColor_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.AllowAll);
Example #11
0
 public void HadamardTransform_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunHadamardTransformTest, HwIntrinsics.AllowAll);
Example #12
0
 static void RunTest(string serialized)
 {
     TestImpl_BulkConvertByteToNormalizedFloat(
         FeatureTestRunner.Deserialize <int>(serialized),
         (s, d) => SimdUtils.HwIntrinsics.ByteToNormalizedFloat(s.Span, d.Span));
 }
Example #13
0
 public void TwoInverseTransform_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTwoInverseTransformTest, HwIntrinsics.AllowAll);
Example #14
0
 public void FTransform2_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunFTransform2Test, HwIntrinsics.AllowAll);
Example #15
0
 public void Predictor13_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.DisableSSE2);
Example #16
0
 public void Predictor13_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.AllowAll);
Example #17
0
 public void CombinedShannonEntropy_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCombinedShannonEntropyTest, HwIntrinsics.DisableAVX2);
Example #18
0
 public void CombinedShannonEntropy_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCombinedShannonEntropyTest, HwIntrinsics.AllowAll);
 public void CheckNonOpaque_WithNoneOpaquePixels_WithoutAvx2_Works()
 => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.DisableAVX2);
 public void CheckNonOpaque_WithNoneOpaquePixels_WithHardwareIntrinsics_Works()
 => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.AllowAll);
Example #21
0
 public void Mean16x4_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunMean16x4Test, HwIntrinsics.AllowAll);
Example #22
0
 public void RunEncodeLossy_WithPeakImage_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunEncodeLossy_WithPeakImage, HwIntrinsics.AllowAll);
Example #23
0
 public void RunEncodeLossy_WithPeakImage_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunEncodeLossy_WithPeakImage, HwIntrinsics.DisableHWIntrinsic);
Example #24
0
 public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSSE3);
Example #25
0
 public void FTransform2_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunFTransform2Test, HwIntrinsics.DisableHWIntrinsic);
Example #26
0
 public void AddGreenToBlueAndRed_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.AllowAll);
Example #27
0
 public void TwoInverseTransform_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTwoInverseTransformTest, HwIntrinsics.DisableHWIntrinsic);
Example #28
0
 public void AddGreenToBlueAndRed_WithoutAVX2OrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableSSSE3);
Example #29
0
 public void SubtractGreen_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.AllowAll);
Example #30
0
 public void Mean16x4_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunMean16x4Test, HwIntrinsics.DisableHWIntrinsic);