IVGCVSW-3140 Fix Hal 1.1 Softmax failures on Android Q

 * Add support for Softmax Axis parameter.

!armnn:1567

Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Change-Id: I7e47d36f13b122dbad7976c0d59773845bc182b1
diff --git a/1.2/HalPolicy.cpp b/1.2/HalPolicy.cpp
index 5fe54d8..3c00388 100644
--- a/1.2/HalPolicy.cpp
+++ b/1.2/HalPolicy.cpp
@@ -46,7 +46,6 @@
         case V1_0::OperationType::RELU6:
         case V1_0::OperationType::RESHAPE:
         case V1_0::OperationType::RNN:
-        case V1_0::OperationType::SOFTMAX:
         case V1_0::OperationType::SPACE_TO_DEPTH:
         case V1_0::OperationType::SVDF:
         case V1_0::OperationType::TANH:
@@ -154,6 +153,8 @@
             return ConvertResize(operation, model, data, armnn::ResizeMethod::Bilinear);
         case V1_2::OperationType::RESIZE_NEAREST_NEIGHBOR:
             return ConvertResize(operation, model, data, armnn::ResizeMethod::NearestNeighbor);
+        case V1_2::OperationType::SOFTMAX:
+            return ConvertSoftmax(operation, model, data);
         default:
             return Fail("%s: Operation type %s not supported in ArmnnDriver",
                         __func__, toString(operation.type).c_str());
@@ -945,5 +946,67 @@
     return SetupAndTrackLayerOutputSlot<hal_1_2::HalPolicy>(operation, 0, *layer, model, data);
 }
 
+bool HalPolicy::ConvertSoftmax(const Operation& operation, const Model& model, ConversionData& data)
+{
+    LayerInputHandle input = ConvertToLayerInputHandle<hal_1_2::HalPolicy>(operation, 0, model, data);
+    if (!input.IsValid())
+    {
+        return Fail("%s: Operation has invalid inputs", __func__);
+    }
+
+    const Operand* outputOperand = GetOutputOperand<hal_1_2::HalPolicy>(operation, 0, model);
+    if (!outputOperand)
+    {
+        return Fail("%s: Operation has no outputs", __func__);
+    }
+
+    armnn::TensorInfo outputInfo = GetTensorInfoForOperand(*outputOperand);
+    if (IsDynamicOutput(outputInfo))
+    {
+        ALOGD("Output shape not set, will infer from input");
+        outputInfo.SetShape(input.GetTensorInfo().GetShape());
+    }
+
+    armnn::SoftmaxDescriptor desc;
+    if (!GetInputFloat32<hal_1_2::HalPolicy>(operation, 1, desc.m_Beta, model, data))
+    {
+        return Fail("%s: Operation has invalid inputs", __func__);
+    }
+
+    if (operation.inputs.size() > 2 && !GetInputScalar<hal_1_2::HalPolicy>(operation,
+                                                                           2,
+                                                                           HalPolicy::OperandType::INT32,
+                                                                           desc.m_Axis,
+                                                                           model,
+                                                                           data))
+    {
+        return Fail("%s: Operation has invalid inputs", __func__);
+    }
+
+    bool isSupported = false;
+    FORWARD_LAYER_SUPPORT_FUNC(__func__,
+                               IsSoftmaxSupported,
+                               data.m_Backends,
+                               isSupported,
+                               input.GetTensorInfo(),
+                               outputInfo,
+                               desc);
+    if (!isSupported)
+    {
+        return false;
+    }
+
+    armnn::IConnectableLayer* layer = data.m_Network->AddSoftmaxLayer(desc);
+    assert(layer != nullptr);
+    input.Connect(layer->GetInputSlot(0));
+
+    return SetupAndTrackLayerOutputSlot<hal_1_2::HalPolicy>(operation,
+                                                            0,
+                                                            *layer,
+                                                            model,
+                                                            data,
+                                                            armnn::Optional<armnn::TensorInfo>(outputInfo));
+}
+
 } // namespace hal_1_2
 } // namespace armnn_driver
diff --git a/1.2/HalPolicy.hpp b/1.2/HalPolicy.hpp
index 18cf035..3c4906c 100644
--- a/1.2/HalPolicy.hpp
+++ b/1.2/HalPolicy.hpp
@@ -48,6 +48,8 @@
                               ConversionData& data,
                               armnn::ResizeMethod resizeMethod);
 
+    static bool ConvertSoftmax(const Operation& operation, const Model& model, ConversionData& data);
+
     static bool ConvertSpaceToDepth(const Operation& operation, const Model& model, ConversionData& data);
 };
 
diff --git a/NnapiSupport.txt b/NnapiSupport.txt
index 8c7a814..a57768d 100644
--- a/NnapiSupport.txt
+++ b/NnapiSupport.txt
@@ -54,6 +54,7 @@
 MINIMUM                      (FLOAT32,QUANT8_ASYMM)
 PRELU                        (FLOAT32,QUANT8_ASYMM)
 RESIZE_NEAREST_NEIGHBOR      (FLOAT32,QUANT8_ASYMM)
+SOFTMAX                      (FLOAT32,QUANT8_ASYMM)
 
 --- Unsupported operators ---