Compute Library
 22.08
CLConcatenateLayer Class Reference

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

#include <CLConcatenateLayer.h>

Collaboration diagram for CLConcatenateLayer:
[legend]

Public Member Functions

 CLConcatenateLayer ()
 Default constructor. More...
 
 ~CLConcatenateLayer ()
 Destructor. More...
 
 CLConcatenateLayer (const CLConcatenateLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLConcatenateLayer (CLConcatenateLayer &&)
 Default move constructor. More...
 
CLConcatenateLayeroperator= (const CLConcatenateLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLConcatenateLayeroperator= (CLConcatenateLayer &&)
 Default move assignment operator. More...
 
void configure (std::vector< const ICLTensor *> &inputs_vector, ICLTensor *output, size_t axis)
 Initialise the kernel's inputs vector and output. More...
 
void configure (const CLCompileContext &compile_context, std::vector< const ICLTensor *> &inputs_vector, ICLTensor *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 CLConcatenateLayer. More...
 

Detailed Description

Basic function to execute concatenate tensors along a given axis.

This function calls the following kernels:

  1. opencl::kernels::ClWidthConcatenateKernel (if underlying concatenation axis is 0).
  2. opencl::kernels::ClHeightConcatenateKernel (if underlying concatenation axis is 1).
  3. opencl::kernels::ClDepthConcatenateKernel (if underlying concatenation axis is 2).
  4. opencl::kernels::ClBatchConcatenateKernel (if underlying concatenation axis is 3).

Definition at line 50 of file CLConcatenateLayer.h.

Constructor & Destructor Documentation

◆ CLConcatenateLayer() [1/3]

Default constructor.

Definition at line 43 of file CLConcatenateLayer.cpp.

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

44  : _impl(std::make_unique<Impl>())
45 {
46 }

◆ ~CLConcatenateLayer()

~CLConcatenateLayer ( )
default

Destructor.

Referenced by CLConcatenateLayer::CLConcatenateLayer().

◆ CLConcatenateLayer() [2/3]

CLConcatenateLayer ( const CLConcatenateLayer )
delete

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

◆ CLConcatenateLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

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

Initialise the kernel's inputs vector and output.

Valid data layouts:

  • All

Valid data type configurations:

src dst
QASYMM8 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED
F16 F16
F32 F32
Note
Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Preconditions can be found respectively at opencl::kernels::ClWidthConcatenateKernel, opencl::kernels::ClHeightConcatenateKernel and opencl::kernels::ClDepthConcatenateKernel.
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 54 of file CLConcatenateLayer.cpp.

References CLKernelLibrary::get().

Referenced by CLLSTMLayerQuantized::configure(), and CLLSTMLayer::configure().

55 {
56  configure(CLKernelLibrary::get().get_compile_context(), inputs_vector, output, axis);
57 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(std::vector< const ICLTensor *> &inputs_vector, ICLTensor *output, size_t axis)
Initialise the kernel&#39;s inputs vector and output.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
std::vector< const ICLTensor *> &  inputs_vector,
ICLTensor 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 opencl::kernels::ClWidthConcatenateKernel, opencl::kernels::ClHeightConcatenateKernel and opencl::kernels::ClDepthConcatenateKernel.
Parameters
[in]compile_contextThe compile context to be used.
[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 59 of file CLConcatenateLayer.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, and ARM_COMPUTE_LOG_PARAMS.

60 {
61  ARM_COMPUTE_ERROR_ON(output == nullptr);
62  ARM_COMPUTE_LOG_PARAMS(inputs_vector, output, axis);
63 
64  _impl->srcs = inputs_vector;
65  _impl->dst = output;
66  _impl->axis = axis;
67  _impl->num_inputs = inputs_vector.size();
68  _impl->op = std::make_unique<opencl::ClConcatenate>();
69 
70  std::vector<ITensorInfo *> inputs_vector_info;
71  for(unsigned int i = 0; i < inputs_vector.size(); ++i)
72  {
73  ARM_COMPUTE_ERROR_ON_NULLPTR(inputs_vector.at(i));
74  inputs_vector_info.emplace_back(inputs_vector.at(i)->info());
75  }
76  _impl->op->configure(compile_context, inputs_vector_info, _impl->dst->info(), axis);
77 }
#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_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ operator=() [1/2]

CLConcatenateLayer& operator= ( const CLConcatenateLayer )
delete

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

Referenced by CLConcatenateLayer::CLConcatenateLayer().

◆ operator=() [2/2]

CLConcatenateLayer & operator= ( CLConcatenateLayer &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For CPU 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 84 of file CLConcatenateLayer.cpp.

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

Referenced by CLLSTMLayerQuantized::prepare(), CLLSTMLayer::prepare(), CLLSTMLayerQuantized::run(), and CLLSTMLayer::run().

85 {
86  ITensorPack pack;
87  for(unsigned i = 0; i < _impl->num_inputs; ++i)
88  {
89  pack.add_tensor(TensorType::ACL_SRC_VEC + i, _impl->srcs.at(i));
90  }
91  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
92 
93  _impl->op->run(pack);
94 }
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ 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 CLConcatenateLayer.

Note
Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Preconditions can be found respectively at opencl::kernels::ClWidthConcatenateKernel, opencl::kernels::ClHeightConcatenateKernel and opencl::kernels::ClDepthConcatenateKernel.
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 79 of file CLConcatenateLayer.cpp.

References ClConcatenate::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), CLLSTMLayerQuantized::validate(), and CLLSTMLayer::validate().

80 {
81  return opencl::ClConcatenate::validate(inputs_vector, output, axis);
82 }
static Status validate(const std::vector< const ITensorInfo *> &src_vector, const ITensorInfo *dst, size_t axis)
Static function to check if given info will lead to a valid configuration.

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