ArmNN  NotReleased
AbsLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "AbsLayer.hpp"
7 
8 #include "LayerCloneBase.hpp"
9 
10 #include <armnn/TypesUtils.hpp>
13 
14 namespace armnn
15 {
16 
17 AbsLayer::AbsLayer(const char* name)
18  : Layer(1, 1, LayerType::Abs, name)
19 {
20 }
21 
22 std::unique_ptr<IWorkload> AbsLayer::CreateWorkload(const IWorkloadFactory& factory) const
23 {
24  AbsQueueDescriptor descriptor;
25  return factory.CreateAbs(descriptor, PrepInfoAndDesc(descriptor));
26 }
27 
29 {
30  return CloneBase<AbsLayer>(graph, GetName());
31 }
32 
34 {
36 
37  auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
38 
39  BOOST_ASSERT(inferredShapes.size() == 1);
40 
41  ConditionalThrowIfNotEqual<LayerValidationException>(
42  "AbsLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
44  inferredShapes[0]);
45 }
46 
47 void AbsLayer::Accept(ILayerVisitor& visitor) const
48 {
49  visitor.VisitAbsLayer(this, GetName());
50 }
51 
52 } // namespace armnn
void Accept(ILayerVisitor &visitor) const override
Definition: AbsLayer.cpp:47
const char * GetName() const override
Definition: Layer.hpp:305
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
Definition: Layer.cpp:370
virtual const TensorInfo & GetTensorInfo() const =0
virtual std::unique_ptr< IWorkload > CreateAbs(const AbsQueueDescriptor &descriptor, const WorkloadInfo &info) const
virtual void VisitAbsLayer(const IConnectableLayer *layer, const char *name=nullptr)=0
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:344
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Definition: AbsLayer.cpp:22
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
void ValidateTensorShapesFromInputs() override
Definition: AbsLayer.cpp:33
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:337
AbsLayer * Clone(Graph &graph) const override
Definition: AbsLayer.cpp:28
AbsLayer(const char *name)
Definition: AbsLayer.cpp:17
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312
const InputSlot & GetInputSlot(unsigned int index) const override
Definition: Layer.hpp:310