ArmNN  NotReleased
MemCopyLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "MemCopyLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
9 #include <armnn/TypesUtils.hpp>
13 
14 namespace armnn
15 {
16 
17 MemCopyLayer::MemCopyLayer(const char* name)
18  : Layer(1, 1, LayerType::MemCopy, name)
19 {
20 }
21 
23 {
24  return CloneBase<MemCopyLayer>(graph, GetName());
25 }
26 
27 std::unique_ptr<IWorkload> MemCopyLayer::CreateWorkload(const IWorkloadFactory& factory) const
28 {
29  boost::ignore_unused(factory);
30  MemCopyQueueDescriptor descriptor;
31 
32  //This is different from other workloads. Does not get created by the workload factory.
33  return std::make_unique<CopyMemGenericWorkload>(descriptor, PrepInfoAndDesc(descriptor));
34 }
35 
37 {
39 
40  auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
41 
42  BOOST_ASSERT(inferredShapes.size() == 1);
43 
44  ConditionalThrowIfNotEqual<LayerValidationException>(
45  "MemCopyLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
47  inferredShapes[0]);
48 }
49 
50 void MemCopyLayer::Accept(ILayerVisitor& visitor) const
51 {
52  boost::ignore_unused(visitor);
53  throw armnn::Exception("MemCopyLayer should not appear in an input graph");
54 }
55 
56 } // namespace armnn
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
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:344
This layer represents a memory copy operation.
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
MemCopyLayer * Clone(Graph &graph) const override
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:337
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
void ValidateTensorShapesFromInputs() override
void Accept(ILayerVisitor &visitor) const override
MemCopyLayer(const char *name)
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