Compute Library
 21.02
NEConcatenateLayer Class Reference

Basic function to execute concatenate tensors along a given axis. More...

#include <NEConcatenateLayer.h>

Collaboration diagram for NEConcatenateLayer:
[legend]

Public Member Functions

 NEConcatenateLayer ()
 Default constructor. More...
 
 ~NEConcatenateLayer ()
 Destructor. More...
 
 NEConcatenateLayer (const NEConcatenateLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEConcatenateLayer (NEConcatenateLayer &&)
 Default move constructor. More...
 
NEConcatenateLayeroperator= (const NEConcatenateLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEConcatenateLayeroperator= (NEConcatenateLayer &&)
 Default move assignment operator. More...
 
void configure (std::vector< const ITensor *> inputs_vector, ITensor *output, size_t axis)
 Initialise the kernel's inputs vector and output. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const std::vector< const ITensorInfo *> &inputs_vector, const ITensorInfo *output, size_t axis)
 Static function to check if given info will lead to a valid configuration of NEConcatenateLayer. More...
 

Detailed Description

Basic function to execute concatenate tensors along a given axis.

Definition at line 41 of file NEConcatenateLayer.h.

Constructor & Destructor Documentation

◆ NEConcatenateLayer() [1/3]

Default constructor.

Definition at line 48 of file NEConcatenateLayer.cpp.

References NEConcatenateLayer::operator=(), and NEConcatenateLayer::~NEConcatenateLayer().

49  : _impl(std::make_unique<Impl>())
50 {
51 }

◆ ~NEConcatenateLayer()

~NEConcatenateLayer ( )
default

Destructor.

Referenced by NEConcatenateLayer::NEConcatenateLayer().

◆ NEConcatenateLayer() [2/3]

NEConcatenateLayer ( const NEConcatenateLayer )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEConcatenateLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure()

void configure ( std::vector< const ITensor *>  inputs_vector,
ITensor output,
size_t  axis 
)

Initialise the kernel's inputs vector and output.

Note
Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Preconditions can be found respectively at cpu::kernels::CpuConcatenateWidthKernel, cpu::kernels::CpuConcatenateHeightKernel, cpu::kernels::CpuConcatenateDepthKernel and cpu::kernels::CpuConcatenateBatchKernel.
Parameters
[in,out]inputs_vectorThe vectors containing all the tensors to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[out]outputOutput tensor. Data types supported: Same as input.
[in]axisConcatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.

Definition at line 56 of file NEConcatenateLayer.cpp.

References ARM_COMPUTE_ERROR_ON, and ARM_COMPUTE_ERROR_ON_NULLPTR.

Referenced by NELSTMLayer::configure(), and NELSTMLayerQuantized::configure().

57 {
58  ARM_COMPUTE_ERROR_ON(output == nullptr);
59 
60  _impl->srcs = inputs_vector;
61  _impl->dst = output;
62  _impl->axis = axis;
63  _impl->num_inputs = inputs_vector.size();
64  _impl->op = std::make_unique<cpu::CpuConcatenate>();
65 
66  std::vector<const ITensorInfo *> inputs_vector_info;
67  for(unsigned int i = 0; i < inputs_vector.size(); ++i)
68  {
69  ARM_COMPUTE_ERROR_ON_NULLPTR(inputs_vector.at(i));
70  inputs_vector_info.emplace_back(inputs_vector.at(i)->info());
71  }
72  _impl->op->configure(inputs_vector_info, _impl->dst->info(), axis);
73 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ operator=() [1/2]

NEConcatenateLayer& operator= ( const NEConcatenateLayer )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEConcatenateLayer::NEConcatenateLayer().

◆ operator=() [2/2]

NEConcatenateLayer & operator= ( NEConcatenateLayer &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 80 of file NEConcatenateLayer.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC_VEC, and ITensorPack::add_tensor().

Referenced by NELSTMLayerQuantized::prepare(), NELSTMLayer::prepare(), NELSTMLayerQuantized::run(), and NELSTMLayer::run().

81 {
82  ITensorPack pack;
83  for(unsigned i = 0; i < _impl->num_inputs; ++i)
84  {
85  pack.add_tensor(TensorType::ACL_SRC_VEC + i, _impl->srcs.at(i));
86  }
87  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
88 
89  _impl->op->run(pack);
90 }

◆ validate()

Status validate ( const std::vector< const ITensorInfo *> &  inputs_vector,
const ITensorInfo output,
size_t  axis 
)
static

Static function to check if given info will lead to a valid configuration of NEConcatenateLayer.

Note
Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Preconditions can be found respectively at cpu::kernels::CpuConcatenateWidthKernel, cpu::kernels::CpuConcatenateHeightKernel, cpu::kernels::CpuConcatenateDepthKernel and cpu::kernels::CpuConcatenateBatchKernel.
Parameters
[in]inputs_vectorThe vectors containing all the tensors info to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]outputOutput tensor info. Data types supported: Same as input.
[in]axisConcatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.
Returns
a status

Definition at line 75 of file NEConcatenateLayer.cpp.

References CpuConcatenate::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), NELSTMLayerQuantized::validate(), and NELSTMLayer::validate().

76 {
77  return cpu::CpuConcatenate::validate(inputs_vector, output, axis);
78 }
static Status validate(const std::vector< const ITensorInfo *> &srcs_vector, const ITensorInfo *dst, size_t axis)
Static function to check if given info will lead to a valid configuration of NEConcatenateLayer.

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