Compute Library
 19.08
NEReshapeLayerKernel Class Reference

Interface for the kernel to perform tensor reshaping. More...

#include <NEReshapeLayerKernel.h>

Collaboration diagram for NEReshapeLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
void configure (const ITensor *input, ITensor *output)
 Set the input and output of the kernel. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPSimpleKernel
 ICPPSimpleKernel ()
 Constructor. More...
 
 ICPPSimpleKernel (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICPPSimpleKerneloperator= (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICPPSimpleKernel (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
ICPPSimpleKerneloperator= (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~ICPPSimpleKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. 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)
 Static function to check if given info will lead to a valid configuration of NEReshapeLayerKernel. More...
 

Detailed Description

Interface for the kernel to perform tensor reshaping.

Definition at line 34 of file NEReshapeLayerKernel.h.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Set the input and output of the kernel.

Parameters
[in]inputSource tensor. Data type supported: U8/S8/U16/S16/QASYMM8/U32/S32/F16/F32
[out]outputDestination tensor. Data type supported: Same as input

Definition at line 75 of file NEReshapeLayerKernel.cpp.

76 {
77  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
78  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
79 
80  _input = input;
81  _output = output;
82 
83  // Configure kernel window
84  Window win = calculate_max_window(*input->info());
85 
86  // Set the output valid region
87  output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
88 
89  INEKernel::configure(win);
90 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Coordinates of an item.
Definition: Coordinates.h:37
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::calculate_max_window(), ITensor::info(), ITensorInfo::set_valid_region(), and ITensorInfo::tensor_shape().

Referenced by NESoftmaxLayer::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 37 of file NEReshapeLayerKernel.h.

38  {
39  return "NEReshapeLayerKernel";
40  }

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

Implements ICPPKernel.

Definition at line 99 of file NEReshapeLayerKernel.cpp.

100 {
104 
105  switch(_input->info()->data_type())
106  {
107  case DataType::U8:
108  case DataType::S8:
109  case DataType::QASYMM8:
110  reshape_tensor<uint8_t>(window, _input, _output);
111  break;
112  case DataType::U16:
113  case DataType::S16:
114  case DataType::F16:
115  reshape_tensor<uint16_t>(window, _input, _output);
116  break;
117  case DataType::U32:
118  case DataType::S32:
119  case DataType::F32:
120  reshape_tensor<uint32_t>(window, _input, _output);
121  break;
122  default:
123  ARM_COMPUTE_ERROR("Unsupported data type!");
124  }
125 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
1 channel, 1 U16 per channel
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
1 channel, 1 U32 per channel
quantized, asymmetric fixed-point 8-bit number
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
signed 8-bit number
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::F16, arm_compute::F32, arm_compute::test::validation::info, arm_compute::QASYMM8, arm_compute::S16, arm_compute::S32, arm_compute::S8, arm_compute::U16, arm_compute::U32, arm_compute::U8, and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output 
)
static

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

Parameters
[in]inputSource tensor info. Data type supported: U8/S8/U16/S16/QASYMM8/U32/S32/F16/F32
[in]outputDestination tensor info. Data type supported: Same as input
Returns
a status

Definition at line 92 of file NEReshapeLayerKernel.cpp.

93 {
94  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
95 
96  return Status{};
97 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEReshapeLayer::validate(), and NESoftmaxLayer::validate().


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