Compute Library
 21.02
NEChannelShuffleLayerKernel Class Reference

Interface for the channel shuffle kernel. More...

#include <NEChannelShuffleLayerKernel.h>

Collaboration diagram for NEChannelShuffleLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEChannelShuffleLayerKernel ()
 Default constructor. More...
 
 NEChannelShuffleLayerKernel (const NEChannelShuffleLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEChannelShuffleLayerKerneloperator= (const NEChannelShuffleLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEChannelShuffleLayerKernel (NEChannelShuffleLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEChannelShuffleLayerKerneloperator= (NEChannelShuffleLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEChannelShuffleLayerKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, unsigned int num_groups)
 Configure function's inputs and outputs. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, unsigned int num_groups)
 Static function to check if given info will lead to a valid configuration of NEChannelShuffleLayerKernel. More...
 

Detailed Description

Interface for the channel shuffle kernel.

Definition at line 35 of file NEChannelShuffleLayerKernel.h.

Constructor & Destructor Documentation

◆ NEChannelShuffleLayerKernel() [1/3]

Default constructor.

Definition at line 136 of file NEChannelShuffleLayerKernel.cpp.

Referenced by NEChannelShuffleLayerKernel::name().

137  : _input(nullptr), _output(nullptr), _num_groups()
138 {
139 }

◆ NEChannelShuffleLayerKernel() [2/3]

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

◆ NEChannelShuffleLayerKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEChannelShuffleLayerKernel()

Default destructor.

Referenced by NEChannelShuffleLayerKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output,
unsigned int  num_groups 
)

Configure function's inputs and outputs.

Parameters
[in]inputInput tensor. Data types supported: All
[out]outputOutput tensor. Data type supported: Same as input
[in]num_groupsNumber of groups. Must be greater than 1 and the number of channels of the tensors must be a multiple of the number of groups.

Definition at line 141 of file NEChannelShuffleLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), ITensor::info(), arm_compute::test::validation::input, ITensorInfo::num_dimensions(), arm_compute::test::validation::num_groups, Dimensions< T >::set_num_dimensions(), ITensorInfo::set_valid_region(), ITensorInfo::tensor_shape(), and arm_compute::validate_arguments().

Referenced by NEChannelShuffleLayerKernel::name().

142 {
144 
145  // Output tensor auto initialization if not yet initialized
146  auto_init_if_empty(*output->info(), *input->info()->clone());
147 
148  _input = input;
149  _output = output;
150  _num_groups = num_groups;
151 
153 
154  // Configure kernel window
155  Window win = calculate_max_window(*input->info(), Steps());
156 
157  // The NEChannelShuffleLayerKernel doesn't need padding so update_window_and_padding() can be skipped
158  Coordinates coord;
159  coord.set_num_dimensions(output->info()->num_dimensions());
160  output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
161 
162  INEKernel::configure(win);
163 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
const unsigned int num_groups
Definition: Im2Col.cpp:153
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...
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ name()

◆ operator=() [1/2]

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

Referenced by NEChannelShuffleLayerKernel::name().

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 171 of file NEChannelShuffleLayerKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_layout(), ITensor::info(), arm_compute::NCHW, arm_compute::NHWC, and IKernel::window().

Referenced by NEChannelShuffleLayerKernel::name().

172 {
176 
177  switch(_input->info()->data_layout())
178  {
179  case DataLayout::NHWC:
180  channel_shuffle_nhwc(_input, _output, _num_groups, window);
181  break;
182  case DataLayout::NCHW:
183  channel_shuffle_nchw(_input, _output, _num_groups, window);
184  break;
185  default:
186  ARM_COMPUTE_ERROR("Unsupported data layout!");
187  break;
188  }
189 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
Num samples, channels, height, width.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Num samples, height, width, channels.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
unsigned int  num_groups 
)
static

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

Parameters
[in]inputInput tensor. Data types supported: All
[out]outputOutput tensor. Data type supported: Same as input
[in]num_groupsNumber of groups. Must be greater than 1 and the number of channels of the tensors must be a multiple of the number of groups.
Returns
a status

Definition at line 165 of file NEChannelShuffleLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, and arm_compute::validate_arguments().

Referenced by NEChannelShuffleLayerKernel::name(), and NEChannelShuffleLayer::validate().

166 {
168  return Status{};
169 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
const unsigned int num_groups
Definition: Im2Col.cpp:153
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

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