Compute Library
GCConcatenateLayer Class Reference

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

#include <GCConcatenateLayer.h>

Collaboration diagram for GCConcatenateLayer:

Public Member Functions

 GCConcatenateLayer ()
 Default constructor. More...
void configure (std::vector< IGCTensor *> inputs_vector, IGCTensor *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...

Detailed Description

Basic function to execute concatenate tensors along a given axis.

This function calls the following kernels:

only axis z is supported
  1. GCDepthConcatenateLayerKernel
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 47 of file GCConcatenateLayer.h.

Constructor & Destructor Documentation

◆ GCConcatenateLayer()

Default constructor.

Definition at line 36 of file GCConcatenateLayer.cpp.

37  : _concat_kernels(),
38  _num_inputs(0),
39  _axis(Window::DimZ)
40 {
41 }
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47

Member Function Documentation

◆ configure()

void configure ( std::vector< IGCTensor *>  inputs_vector,
IGCTensor output,
size_t  axis 

Initialise the kernel's inputs vector and output.

Input and output tensor dimensions preconditions defer depending on the concatenation axis.
[in,out]inputs_vectorThe vectors containing all the tensors to concatenate. Data types supported: F16/F32.
[out]outputOutput tensor. Data types supported: Same as input.
[in]axisConcatenation axis. Supported underlying concatenation axis is 2.

Definition at line 43 of file GCConcatenateLayer.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, arm_compute::auto_init_if_empty(), arm_compute::misc::shape_calculator::calculate_concatenate_shape(), Window::DimZ, ITensor::info(), offset(), and arm_compute::test::validation::output_shape.

44 {
45  ARM_COMPUTE_ERROR_ON(inputs_vector.size() < 2);
47  _num_inputs = inputs_vector.size();
48  _axis = axis;
52  // Output auto inizialitation if not yet initialized
53  auto_init_if_empty(*output->info(), output_shape, 1, inputs_vector[0]->info()->data_type());
55  unsigned int offset = 0;
56  switch(axis)
57  {
58  case Window::DimZ:
59  {
60  for(unsigned int i = 0; i < _num_inputs; ++i)
61  {
62  auto kernel = std::make_unique<GCDepthConcatenateLayerKernel>();
63  kernel->configure(, offset, output);
64  offset +=>info()->dimension(axis);
65  _concat_kernels.emplace_back(std::move(kernel));
66  }
67  break;
68  }
69  default:
70  ARM_COMPUTE_ERROR("Axis not supported");
71  }
72 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#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
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
TensorShape calculate_concatenate_shape(const std::vector< T *> &input, size_t axis)
Calculate the concatenate output shape of the concatenate operation along a single axis...

◆ run()

void run ( )

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.
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.
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 74 of file GCConcatenateLayer.cpp.

References GCScheduler::dispatch(), and GCScheduler::get().

75 {
76  for(auto &kernel : _concat_kernels)
77  {
78  GCScheduler::get().dispatch(*kernel, true);
79  }
80 }
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: GCScheduler.cpp:77
static GCScheduler & get()
Access the scheduler singleton.
Definition: GCScheduler.cpp:70

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