Compute Library
 21.08
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...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. 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, and arm_compute::test::validation::num_groups.

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 
152  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), num_groups));
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  INEKernel::configure(win);
159 }
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...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ 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 167 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().

168 {
172 
173  switch(_input->info()->data_layout())
174  {
175  case DataLayout::NHWC:
176  channel_shuffle_nhwc(_input, _output, _num_groups, window);
177  break;
178  case DataLayout::NCHW:
179  channel_shuffle_nchw(_input, _output, _num_groups, window);
180  break;
181  default:
182  ARM_COMPUTE_ERROR("Unsupported data layout!");
183  break;
184  }
185 }
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:915
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:201
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 161 of file NEChannelShuffleLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

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

162 {
163  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, num_groups));
164  return Status{};
165 }
#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

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