23.02
|
Go to the documentation of this file.
37 template<
typename FactoryType>
39 const FactoryType& factory,
44 bool useSubTensors = factory.SupportsSubTensors();
56 std::vector<std::unique_ptr<ITensorHandle>> subTensors;
66 std::set<unsigned int> splitAxis;
68 for (
unsigned int i = 0; i < numSplit; ++i)
70 for (
unsigned int dimIdx = 0; dimIdx < numDimensions; ++dimIdx)
74 splitAxis.insert(dimIdx);
82 std::set<unsigned int>::iterator axisIt = axis.begin();
85 ((*axisIt == numberOfDimensions - 1) ||
86 (*axisIt == numberOfDimensions - 2));
99 bool canUseSubTensorOnXorY =
true;
100 bool isTensorHandleFactory = std::is_same<armnn::ITensorHandleFactory, FactoryType>::value;
101 if (isTensorHandleFactory)
103 for (
unsigned int it = 0; it < numOutputSlots; ++it)
106 ITensorHandleFactory* handleFactory = registry.
GetFactory(factoryId);
107 std::vector<Capability> capabilities =
113 canUseSubTensorOnXorY =
false;
114 if (capabilities.empty())
116 canUseSubTensorOnXorY =
true;
120 if (!canUseSubTensorOnXorY)
127 auto CreateSubTensor = [&]()
138 canUseSubTensorOnXorY)
141 return factory.CreateSubTensorHandle(*inputData,
146 return std::unique_ptr<ITensorHandle>();
149 auto subTensor = CreateSubTensor();
152 useSubTensors =
false;
155 subTensors.push_back(std::move(subTensor));
161 for (
auto& subTensor : subTensors)
180 const bool isMemoryManaged)
187 CreateTensors(registry, workloadFactory, isMemoryManaged);
193 CreateTensors(registry, *handleFactory, isMemoryManaged);
206 std::vector<TensorShape> outShapes;
223 std::vector<TensorShape> views;
237 inferredShapes[viewIdx],
virtual void CreateTensorHandles(const TensorHandleFactoryRegistry ®istry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true) override
Set the outputs to be appropriate sub tensors of the input if sub tensors are supported otherwise cre...
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
SplitterLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
uint32_t GetNumViews() const
Get the number of views.
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
const TensorInfo & GetTensorInfo() const
Gets the matching TensorInfo for the output.
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs,...
static const FactoryId LegacyFactoryId
This layer represents a split operation.
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
void IgnoreUnused(Ts &&...)
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
A ViewsDescriptor for the SplitterLayer.
ITensorHandle * GetData() const
Gets the allocated tensor memory.
void SetAdditionalInfo(QueueDescriptor &descriptor) const
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the Splitter type.
ShapeInferenceMethod m_ShapeInferenceMethod
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
uint32_t GetNumDimensions() const
Get the number of dimensions.
Copyright (c) 2021 ARM Limited and Contributors.
virtual std::vector< Capability > GetCapabilities(const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass)
const TensorInfo & GetTensorInfo() const override
std::set< unsigned int > ComputeSplitAxis(const armnn::SplitterDescriptor &desc, const TensorShape &input)
ITensorHandleFactory::FactoryId GetTensorHandleFactoryId() const
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
bool IsTypeSpaceMatch(const TensorInfo &other) const
Check that the types are the same and, if quantize, that the quantization parameters are the same.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
const InputSlot * GetConnection(unsigned int index) const override
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of SplitterLayer.
std::vector< OutputSlot >::iterator BeginOutputSlots()
const TensorShape & GetShape() const
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
std::vector< OutputHandler > m_OutputHandlers
const std::vector< InputSlot > & GetInputSlots() const
std::vector< OutputSlot >::iterator EndOutputSlots()
void Splitter(const SplitterQueueDescriptor &data, std::vector< ITensorHandle * > inputs, std::vector< ITensorHandle * > outputs)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
#define ARMNN_ASSERT(COND)
std::vector< ViewOrigin > m_ViewOrigins
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
const char * GetName() const override
Returns the name of the layer.
const ViewsDescriptor & GetParameters() const override
ViewsDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
SplitterLayer(const ViewsDescriptor ¶m, const char *name)
Constructor to create a SplitterLayer.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
#define ARMNN_NO_DEPRECATE_WARN_END