Compute Library
 22.05
StackLayer Class Referencefinal

Stack Layer. More...

#include <Layers.h>

Collaboration diagram for StackLayer:
[legend]

Public Member Functions

template<typename... Ts>
 StackLayer (SubStream &&sub_stream1, SubStream &&sub_stream2, Ts &&... rest_sub_streams)
 Construct a concatenation layer. More...
 
template<typename... Ts>
 StackLayer (int axis, SubStream &&sub_stream1, SubStream &&sub_stream2, Ts &&... rest_sub_streams)
 Construct a concatenation layer. More...
 
template<typename... Ts>
 StackLayer (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

Stack Layer.

Definition at line 1347 of file Layers.h.

Constructor & Destructor Documentation

◆ StackLayer() [1/3]

StackLayer ( 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 1357 of file Layers.h.

References arm_compute::utility::for_each().

1358  : _sub_streams(), _axis(0)
1359  {
1360  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream1)));
1361  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream2)));
1362 
1363  utility::for_each([&](SubStream && sub_stream)
1364  {
1365  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
1366  },
1367  std::move(rest_sub_streams)...);
1368  }
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:110

◆ StackLayer() [2/3]

StackLayer ( int  axis,
SubStream &&  sub_stream1,
SubStream &&  sub_stream2,
Ts &&...  rest_sub_streams 
)
inline

Construct a concatenation layer.

Parameters
[in]axisStack layer axis along which to stack the inputs
[in]sub_stream1First graph branch
[in]sub_stream2Second graph branch
[in]rest_sub_streamsRest sub-graph branches

Definition at line 1377 of file Layers.h.

References arm_compute::utility::for_each().

1378  : _sub_streams(), _axis(axis)
1379  {
1380  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream1)));
1381  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream2)));
1382 
1383  utility::for_each([&](SubStream && sub_stream)
1384  {
1385  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
1386  },
1387  std::move(rest_sub_streams)...);
1388  }
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:110

◆ StackLayer() [3/3]

StackLayer ( SubStream &&  sub_stream)
inline

Construct a concat layer.

Parameters
[in]sub_streamSub-stream

Definition at line 1394 of file Layers.h.

1395  : _sub_streams(), _axis(0)
1396  {
1397  _sub_streams.push_back(std::make_unique<SubStream>(std::move(sub_stream)));
1398  }

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 1399 of file Layers.h.

References GraphBuilder::add_stack_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.

1400  {
1401  NodeID nid = EmptyNodeID;
1402  NodeParams common_params = { name(), s.hints().target_hint };
1403  if(_sub_streams.size() == 1 && _sub_streams.at(0) != nullptr)
1404  {
1405  nid = _sub_streams[0]->tail_node();
1406  }
1407  else
1408  {
1409  // Collect tail nodes and stack
1410  std::vector<NodeIdxPair> nodes;
1411  for(auto &ss : _sub_streams)
1412  {
1413  if(ss && (ss->tail_node() != EmptyNodeID))
1414  {
1415  const auto tail_node = s.graph().node(ss->tail_node());
1416  if(tail_node != nullptr && tail_node->type() != NodeType::Output)
1417  {
1418  nodes.push_back({ ss->tail_node(), 0 });
1419  }
1420  }
1421  }
1422  nid = GraphBuilder::add_stack_node(s.graph(), common_params, nodes, _axis);
1423  }
1424  return nid;
1425  }
std::stringstream ss(mlgo_str)
static NodeID add_stack_node(Graph &g, NodeParams params, const std::vector< NodeIdxPair > &inputs, int axis)
Adds a stack layer 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: