ARM-software / ComputeLibrary

The Compute Library is a set of computer vision and machine learning functions optimised for both Arm CPUs and GPUs using SIMD technologies.
2.87k stars 782 forks source link

NEScale example get wrong result with Format:RGB888? #1043

Closed regular-time closed 1 year ago

regular-time commented 1 year ago

Output of 'strings libarm_compute.so | grep arm_compute_version': arm_compute_version=v20.05 Build options: {'install_root': '/mnt/not_raid/jenkins_workspace/FAD_build_sdk_flatpak_kernel510/bstos/build/tmp/work/aarch64-bst-linux/arm-compute-library/1.0-r0/image/usr', 'CONFIG_ENVIRONMENT_IMPORT': 'True', 'PREFIX': '/usr', 'prefix': '/usr'} Git hash=6a7771e460abeac7d401d6d38a0fcf0a0d2c3cbe

Platform:

Operating System: Linux

Problem description: I modify the example file neon_scale.cpp to test NEScale: ` bool do_setup(int argc, char **argv) override { PPMLoader ppm; const std::string src_path = "/userdata/workspace/test_hwcv/data/9_input.ppm"; ppm.open(src_path); ppm.init_image(src, Format::RGB888);

    constexpr int scale_factor = 2;

    TensorInfo dst_tensor_info(src.info()->dimension(0) / scale_factor, src.info()->dimension(1) / scale_factor,
                               Format::RGB888);
    // TensorInfo dst_tensor_info(src.info()->dimension(0) / scale_factor, src.info()->dimension(1) / scale_factor,
    //                            Format::U8);

    // Configure the destination image
    dst.allocator()->init(dst_tensor_info);

    // Configure Scale function object:
    scale.configure(&src, &dst, InterpolationPolicy::NEAREST_NEIGHBOR, BorderMode::UNDEFINED);

    // Allocate all the images
    src.allocator()->allocate();
    dst.allocator()->allocate();

    // Fill the input image with the content of the PPM image if a filename was provided:
    if (ppm.is_open())
    {
        ppm.fill_image(src);
        output_filename = std::string("/userdata/workspace/test_hwcv/9_out.ppm");
    }

    return true;
}`

When I run with Format::U8,it works well and get right result. But when I run with Format::RGB888, I get wrong result like this: image

morgolock commented 1 year ago

Hi @regular-time

I noticed you are using 20.05, could you please upgrade to 23.02 and see if the problem persists?

Hope this helps.

morgolock commented 1 year ago

Hi @regular-time

Please see https://github.com/ARM-software/ComputeLibrary/blob/main/arm_compute/runtime/NEON/functions/NEScale.h#L61

The scale function only supports the following data types

     * Valid data type configurations:
     * |src            |dst            |
     * |:--------------|:--------------|
     * |QASYMM8        |QASYMM8        |
     * |QASYMM8_SIGNED |QASYMM8_SIGNED |
     * |F16            |F16            |
     * |F32            |F32            |
     * |U8             |U8             |
     * |S8             |S8             |
     * |S16            |S16            |

The input type Format::RGB888 is not supported by NEScale. You will have to split each channel into three different buffers and run NEScale on each channel and then recreate the RGB888 image.

Hope this helps

regular-time commented 1 year ago

OK, thank you! @morgolock