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.
MIT License
2.82k stars 774 forks source link

NEMeanStdDevNormalizationLayer: support input tensors with 2+ dimensions #1026

Closed alvoron closed 7 months ago

alvoron commented 1 year ago

Hello, I'm using ComputeLibrary in OpenVINO ARM plugin as a backend.

I'm using NEMeanStdDevNormalizationLayer to execute OpenVINO MVN operation: https://docs.openvino.ai/latest/openvino_docs_ops_normalization_MVN_6.html

The issue is input tensors with 2+dimentions are often used in MVN operation and the plugin has to fallback these cases to reference implementation. Is it possible to support input tensors with 2+ dimensions in NEMeanStdDevNormalizationLayer? It would allow as to use ComputeLibrary more often and get more performance.

alvoron commented 1 year ago

Small update: I've implemented the following workaround: ACL has 2D input shape [Y, X] and actual normalization is done over X axis, while Y serves as "batch". We can translate any 2+ dimension MVN shape into ACL representation using the following rules (example for 4D):

NCHW layout, across_channels == false; : Y = NC, X = HW NCHW layout, across_channels == true; : Y = N, X = CHW NHWC layout, across_channels == false; : unsupported NHWC layout, across_channels == true; : Y = N, X = HWC

across_channels is a flag that specifies whether mean values are shared across channels

alvoron commented 8 months ago

Do you have any updates?

morgolock commented 8 months ago

Hi @alvoron

Implementing this feature will require adding a new kernel which would increase the binary size of the library. Since you have a workaround for this problem, we decided it's best to avoid increasing the size of the library and not implementing this feature request.