35 template<
typename FactoryType>
36 void SplitterLayer::CreateTensors(
const FactoryType& factory)
40 bool useSubTensors = factory.SupportsSubTensors();
51 std::vector<std::unique_ptr<ITensorHandle>> subTensors;
60 auto CreateSubTensor = [&]()
66 return factory.CreateSubTensorHandle(*inputData,
70 return std::unique_ptr<ITensorHandle>();
73 auto subTensor = CreateSubTensor();
76 useSubTensors =
false;
79 subTensors.push_back(std::move(subTensor));
85 for (
auto& subTensor : subTensors)
105 const bool IsMemoryManaged)
113 CreateTensors(workloadFactory);
118 BOOST_ASSERT(handleFactory);
119 CreateTensors(*handleFactory);
132 std::vector<TensorShape> outShapes;
144 std::vector<TensorShape> views;
157 ConditionalThrowIfNotEqual<LayerValidationException>(
158 "SplitterLayer: View sizes must match output tensor shapes.",
160 inferredShapes[viewIdx]);
virtual std::unique_ptr< IWorkload > CreateSplitter(const SplitterQueueDescriptor &descriptor, const WorkloadInfo &info) const
SplitterLayer(const ViewsDescriptor ¶m, const char *name)
Constructor to create a SplitterLayer.
This layer represents a split operation.
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...
A ViewsDescriptor for the SplitterLayer.
bool IsTypeSpaceMatch(const TensorInfo &other) const
Check that the types are the same and, if quantize, that the quantization parameters are the same...
ViewsDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const ViewsDescriptor & GetParameters() const
const TensorShape & GetShape() const
uint32_t GetNumDimensions() const
Get the number of dimensions.
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, otherwise infers the output shapes from given input shapes and layer properties.
uint32_t GetNumViews() const
Get the number of views.
Copyright (c) 2020 ARM Limited.
void IgnoreUnused(Ts &&...)
const std::vector< InputSlot > & GetInputSlots() const
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
ITensorHandle * GetData() const
Gets the allocated tensor memory.
std::vector< OutputHandler > m_OutputHandlers
std::vector< ViewOrigin > m_ViewOrigins
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
virtual void VisitSplitterLayer(const IConnectableLayer *layer, const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)=0
Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoke...
ClWorkloadFactory FactoryType
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
const char * GetName() const override
Returns the name of the layer.
ITensorHandleFactory::FactoryId GetTensorHandleFactoryId() const
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of SplitterLayer.
void Splitter(const SplitterQueueDescriptor &data)
const TensorInfo & GetTensorInfo() const override
static const FactoryId LegacyFactoryId
SplitterLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the Splitter type.
const TensorInfo & GetTensorInfo() const
Gets the matching TensorInfo for the output.