Compute Library
 22.05
ConcatLayer Class Referencefinal

Concat Layer. More...

#include <Layers.h>

Collaboration diagram for ConcatLayer:
[legend]

Public Member Functions

template<typename... Ts>
 ConcatLayer (SubStream &&sub_stream1, SubStream &&sub_stream2, Ts &&... rest_sub_streams)
 Construct a concatenation layer. More...
 
template<typename... Ts>
 ConcatLayer (descriptors::ConcatLayerDescriptor concat_descriptor, SubStream &&sub_stream1, SubStream &&sub_stream2, Ts &&... rest_sub_streams)
 Construct a concatenation layer. More...
 
template<typename... Ts>
 ConcatLayer (SubStream &&sub_stream)
 Construct a concat layer. More...
 
NodeID create_layer (IStream &s) override
 Create layer and add to the given stream. More...
 
- Public Member Functions inherited from ILayer
virtual ~ILayer ()=default
 Default destructor. More...
 
ILayerset_name (std::string name)
 Sets the name of the layer. More...
 
const std::string & name () const
 Layer name accessor. More...
 

Detailed Description

Concat Layer.

Definition at line 290 of file Layers.h.

Constructor & Destructor Documentation

◆ ConcatLayer() [1/3]

ConcatLayer ( SubStream &&  sub_stream1,
SubStream &&  sub_stream2,
Ts &&...  rest_sub_streams 
)
inline

Construct a concatenation layer.

Parameters
[in]sub_stream1First graph branch
[in]sub_stream2Second graph branch
[in]rest_sub_streamsRest sub-graph branches

Definition at line 300 of file Layers.h.

References arm_compute::CHANNEL, and arm_compute::utility::for_each().

301  : _sub_streams(), _concat_descriptor(DataLayoutDimension::CHANNEL)
302  {
303  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream1)));
304  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream2)));
305 
306  utility::for_each([&](SubStream && sub_stream)
307  {
308  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
309  },
310  std::move(rest_sub_streams)...);
311  }
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:110

◆ ConcatLayer() [2/3]

ConcatLayer ( descriptors::ConcatLayerDescriptor  concat_descriptor,
SubStream &&  sub_stream1,
SubStream &&  sub_stream2,
Ts &&...  rest_sub_streams 
)
inline

Construct a concatenation layer.

Parameters
[in]concat_descriptorConcat layer descriptor
[in]sub_stream1First graph branch
[in]sub_stream2Second graph branch
[in]rest_sub_streamsRest sub-graph branches

Definition at line 320 of file Layers.h.

References arm_compute::utility::for_each().

321  : _sub_streams(), _concat_descriptor(concat_descriptor)
322  {
323  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream1)));
324  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream2)));
325 
326  utility::for_each([&](SubStream && sub_stream)
327  {
328  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
329  },
330  std::move(rest_sub_streams)...);
331  }
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:110

◆ ConcatLayer() [3/3]

ConcatLayer ( SubStream &&  sub_stream)
inline

Construct a concat layer.

Parameters
[in]sub_streamSub-stream

Definition at line 337 of file Layers.h.

References arm_compute::CHANNEL.

338  : _sub_streams(), _concat_descriptor(DataLayoutDimension::CHANNEL)
339  {
340  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
341  }

Member Function Documentation

◆ create_layer()

NodeID create_layer ( IStream s)
inlineoverridevirtual

Create layer and add to the given stream.

Parameters
[in]sStream to add layer to.
Returns
ID of the created node.

Implements ILayer.

Definition at line 342 of file Layers.h.

References GraphBuilder::add_concatenate_node(), arm_compute::graph::EmptyNodeID, IStream::graph(), IStream::hints(), ILayer::name(), Graph::node(), arm_compute::graph::Output, arm_compute::test::validation::ss(), and StreamHints::target_hint.

343  {
344  NodeID nid = EmptyNodeID;
345  NodeParams common_params = { name(), s.hints().target_hint };
346  if(_sub_streams.size() == 1 && _sub_streams.at(0) != nullptr)
347  {
348  nid = _sub_streams[0]->tail_node();
349  }
350  else
351  {
352  // Collect tail nodes and concatenate
353  std::vector<NodeIdxPair> nodes;
354  for(auto &ss : _sub_streams)
355  {
356  if(ss && (ss->tail_node() != EmptyNodeID))
357  {
358  const auto tail_node = s.graph().node(ss->tail_node());
359  if(tail_node != nullptr && tail_node->type() != NodeType::Output)
360  {
361  nodes.push_back({ ss->tail_node(), 0 });
362  }
363  }
364  }
365  nid = GraphBuilder::add_concatenate_node(s.graph(), common_params, nodes, _concat_descriptor);
366  }
367  return nid;
368  }
std::stringstream ss(mlgo_str)
static NodeID add_concatenate_node(Graph &g, NodeParams params, const std::vector< NodeIdxPair > &inputs, const descriptors::ConcatLayerDescriptor &concat_descriptor)
Adds a depth concatenate node to the graph.
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
const std::string & name() const
Layer name accessor.
Definition: ILayer.h:64

The documentation for this class was generated from the following file: