src/armnnUtils/Permute.cpp \
src/armnnUtils/TensorUtils.cpp \
src/armnnUtils/VerificationHelpers.cpp \
+ src/armnn/layers/AbsLayer.cpp \
src/armnn/layers/ActivationLayer.cpp \
src/armnn/layers/AdditionLayer.cpp \
src/armnn/layers/BatchNormalizationLayer.cpp \
include/armnn/Version.hpp
src/armnn/layers/LayerCloneBase.hpp
src/armnn/layers/LayerWithParameters.hpp
+ src/armnn/layers/AbsLayer.hpp
+ src/armnn/layers/AbsLayer.cpp
src/armnn/layers/ActivationLayer.hpp
src/armnn/layers/ActivationLayer.cpp
src/armnn/layers/AdditionLayer.hpp
virtual ~ILayerSupport() {}
public:
+ virtual bool IsAbsSupported(const TensorInfo& input,
+ const TensorInfo& output,
+ Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0;
+
virtual bool IsActivationSupported(const TensorInfo& input,
const TensorInfo& output,
const ActivationDescriptor& descriptor,
virtual ~ILayerVisitor() {}
public:
+ /// Function an absolute layer should call back to when its Accept(ILayerVisitor&)
+ /// function is invoked.
+ /// @param layer - pointer to the layer which is calling back to this visit function.
+ /// @param name - Optional name for the layer.
+ virtual void VisitAbsLayer(const IConnectableLayer* layer,
+ const char* name = nullptr) = 0;
+
/// Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked.
/// @param layer - pointer to the layer which is calling back to this visit function.
/// @param activationDescriptor - ActivationDescriptor to configure the activation.
virtual IConnectableLayer* AddMergerLayer(const MergerDescriptor& mergerDescriptor,
const char* name = nullptr) = 0;
+ /// Add absolute layer to the network.
+ /// @param name - Optional name for the layer.
+ /// @ return - Interface for configuring the layer.
+ virtual IConnectableLayer* AddAbsLayer(const char* name = nullptr) = 0;
+
/// Adds an addition layer to the network.
/// @param name - Optional name for the layer.
/// @return - Interface for configuring the layer.
virtual ~LayerVisitorBase() {}
public:
+ void VisitAbsLayer(const IConnectableLayer*,
+ const char*) override { DefaultPolicy::Apply(__func__); }
void VisitActivationLayer(const IConnectableLayer*,
const ActivationDescriptor&,
enum class LayerType
{
FirstLayer,
- Activation = FirstLayer,
+ Abs = FirstLayer,
+ Activation,
Addition,
BatchNormalization,
BatchToSpaceNd,
#include "InternalTypes.hpp"
+#include "layers/AbsLayer.hpp"
#include "layers/ActivationLayer.hpp"
#include "layers/AdditionLayer.hpp"
#include "layers/BatchNormalizationLayer.hpp"
#define DECLARE_LAYER(LayerName) DECLARE_LAYER_IMPL(, LayerName)
+DECLARE_LAYER(Abs)
DECLARE_LAYER(Activation)
DECLARE_LAYER(Addition)
DECLARE_LAYER(BatchNormalization)
return AddConcatLayer(mergerDescriptor, name);
}
+IConnectableLayer* Network::AddAbsLayer(const char * name)
+{
+ return m_Graph->AddLayer<AbsLayer>(name);
+}
+
IConnectableLayer* Network::AddAdditionLayer(const char* name)
{
return m_Graph->AddLayer<AdditionLayer>(name);
IConnectableLayer* AddMergerLayer(const MergerDescriptor& mergerDescriptor,
const char* name = nullptr) override;
+ IConnectableLayer* AddAbsLayer(const char* name = nullptr) override;
+
IConnectableLayer* AddAdditionLayer(const char* name = nullptr) override;
IConnectableLayer* AddMultiplicationLayer(const char* name = nullptr) override;
--- /dev/null
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "AbsLayer.hpp"
+
+#include "LayerCloneBase.hpp"
+
+#include <armnn/TypesUtils.hpp>
+#include <backendsCommon/WorkloadData.hpp>
+#include <backendsCommon/WorkloadFactory.hpp>
+
+namespace armnn
+{
+
+AbsLayer::AbsLayer(const char* name)
+ : Layer(1, 1, LayerType::Abs, name)
+{
+}
+
+std::unique_ptr<IWorkload> AbsLayer::CreateWorkload(const Graph& graph,
+ const IWorkloadFactory& factory) const
+{
+ AbsQueueDescriptor descriptor;
+ return factory.CreateAbs(descriptor, PrepInfoAndDesc(descriptor, graph));
+}
+
+AbsLayer* AbsLayer::Clone(Graph& graph) const
+{
+ return CloneBase<AbsLayer>(graph, GetName());
+}
+
+void AbsLayer::ValidateTensorShapesFromInputs()
+{
+ VerifyLayerConnections(1, CHECK_LOCATION());
+
+ auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
+
+ BOOST_ASSERT(inferredShapes.size() == 1);
+
+ ConditionalThrowIfNotEqual<LayerValidationException>(
+ "AbsLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
+ GetOutputSlot(0).GetTensorInfo().GetShape(),
+ inferredShapes[0]);
+}
+
+void AbsLayer::Accept(ILayerVisitor& visitor) const
+{
+ visitor.VisitAbsLayer(this, GetName());
+}
+
+} // namespace armnn
\ No newline at end of file
--- /dev/null
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <Layer.hpp>
+
+namespace armnn
+{
+
+class AbsLayer : public Layer
+{
+public:
+ /// Makes a workload for the Abs type.
+ /// @param [in] graph The graph where this layer can be found.
+ /// @param [in] factory The workload factory which will create the workload.
+ /// @return A pointer to the created workload, or nullptr if not created.
+ virtual std::unique_ptr<IWorkload> CreateWorkload(const Graph& graph,
+ const IWorkloadFactory& factory) const override;
+
+ /// Creates a dynamically-allocated copy of this layer.
+ /// @param [in] graph The graph into which this layer is being cloned.
+ AbsLayer* Clone(Graph& graph) const override;
+
+ /// Check if the input tensor shape(s)
+ /// will lead to a valid configuration of @ref AbsLayer.
+ void ValidateTensorShapesFromInputs() override;
+
+ void Accept(ILayerVisitor& visitor) const override;
+
+protected:
+ /// Constructor to create an AbsLayer.
+ /// @param [in] name Optional name for the layer.
+ AbsLayer(const char* name);
+
+ /// Default destructor
+ ~AbsLayer() = default;
+};
+
+} // namespace
\ No newline at end of file
CreateAnyLayer(flatBufferOutputLayer.o, serializer::Layer::Layer_OutputLayer);
}
+void SerializerVisitor::VisitAbsLayer(const armnn::IConnectableLayer* layer, const char* name)
+{
+ throw UnimplementedException("SerializerVisitor::VisitAbsLayer is not implemented");
+}
+
// Build FlatBuffer for Activation Layer
void SerializerVisitor::VisitActivationLayer(const armnn::IConnectableLayer* layer,
const armnn::ActivationDescriptor& descriptor,
return m_serializedLayers;
}
+ void VisitAbsLayer(const armnn::IConnectableLayer* layer,
+ const char* name = nullptr) override;
+
void VisitActivationLayer(const armnn::IConnectableLayer* layer,
const armnn::ActivationDescriptor& descriptor,
const char* name = nullptr) override;
namespace armnn
{
+bool LayerSupportBase::IsAbsSupported(const TensorInfo &input,
+ const TensorInfo &output,
+ Optional<std::string &> reasonIfUnsupported) const
+{
+ return DefaultLayerSupport(__func__, __FILE__, __LINE__, reasonIfUnsupported);
+}
+
bool LayerSupportBase::IsActivationSupported(const TensorInfo& input,
const TensorInfo& output,
const ActivationDescriptor& descriptor,
class LayerSupportBase : public ILayerSupport
{
public:
+ bool IsAbsSupported(const TensorInfo& input,
+ const TensorInfo& output,
+ Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const override;
+
bool IsActivationSupported(const TensorInfo& input,
const TensorInfo& output,
const ActivationDescriptor& descriptor,
ValidateBiasTensorQuantization(outputGateBiasInfo, inputInfo, inputToInputWeightsInfo, descriptorName);
}
+void AbsQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const
+{
+ const std::string descriptorName{"AbsQueueDescriptor"};
+
+ ValidateNumInputs(workloadInfo, descriptorName, 1);
+ ValidateNumOutputs(workloadInfo, descriptorName, 1);
+
+ const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
+ const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
+
+ ValidateTensorShapesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
+
+ std::vector<DataType> supportedTypes =
+ {
+ DataType::Float16,
+ DataType::Float32,
+ DataType::QuantisedAsymm8,
+ DataType::QuantisedSymm16
+ };
+
+ ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName);
+ ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
+}
+
} // namespace armnn
void Validate(const WorkloadInfo& workloadInfo) const;
};
+struct AbsQueueDescriptor : QueueDescriptor
+{
+ void Validate(const WorkloadInfo& workloadInfo) const;
+};
+
} //namespace armnn
switch(layer.GetType())
{
+ case LayerType::Abs:
+ {
+ const TensorInfo& input = layer.GetInputSlot(0).GetConnection()->GetTensorInfo();
+ const TensorInfo& output = layer.GetOutputSlot(0).GetTensorInfo();
+ result = layerSupportObject->IsAbsSupported(OverrideDataType(input, dataType),
+ OverrideDataType(output, dataType),
+ reason);
+ break;
+ }
case LayerType::Activation:
{
auto cLayer = boost::polymorphic_downcast<const ActivationLayer*>(&layer);
}
// Default Implementations
+std::unique_ptr<IWorkload> IWorkloadFactory::CreateAbs(const AbsQueueDescriptor& descriptor,
+ const WorkloadInfo& info) const
+{
+ return std::unique_ptr<IWorkload>();
+}
+
std::unique_ptr<IWorkload> IWorkloadFactory::CreateActivation(const ActivationQueueDescriptor& descriptor,
const WorkloadInfo& info) const
{
virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
DataLayout dataLayout) const = 0;
+ virtual std::unique_ptr<IWorkload> CreateAbs(const AbsQueueDescriptor& descriptor,
+ const WorkloadInfo& info) const;
+
virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor,
const WorkloadInfo& info) const;
struct LayerTypePolicy;
// Every entry in the armnn::LayerType enum must be accounted for below.
+DECLARE_LAYER_POLICY_1_PARAM(Abs)
+
DECLARE_LAYER_POLICY_2_PARAM(Activation)
DECLARE_LAYER_POLICY_1_PARAM(Addition)