Compute Library
 19.08
GCConcatenateLayer Class Reference

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

#include <GCConcatenateLayer.h>

Collaboration diagram for GCConcatenateLayer:
[legend]

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:

Note
only axis z is supported
  1. GCDepthConcatenateLayerKernel

Definition at line 44 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.

Note
Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Parameters
[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.

44 {
45  ARM_COMPUTE_ERROR_ON(inputs_vector.size() < 2);
46 
47  _num_inputs = inputs_vector.size();
48  _axis = axis;
49 
51 
52  // Output auto inizialitation if not yet initialized
53  auto_init_if_empty(*output->info(), output_shape, 1, inputs_vector[0]->info()->data_type());
54 
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 = support::cpp14::make_unique<GCDepthConcatenateLayerKernel>();
63  kernel->configure(inputs_vector.at(i), offset, output);
64  offset += inputs_vector.at(i)->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:328
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
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.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
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...
Definition: Helpers.inl:201
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47

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

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

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:69
static GCScheduler & get()
Access the scheduler singleton.
Definition: GCScheduler.cpp:62

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


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