Compute Library
 22.05
NERangeKernel Class Reference

Kernel class for Range. More...

#include <NERangeKernel.h>

Collaboration diagram for NERangeKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NERangeKernel ()
 Default constructor. More...
 
 NERangeKernel (const NERangeKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NERangeKerneloperator= (const NERangeKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NERangeKernel (NERangeKernel &&)=default
 Allow instances of this class to be moved. More...
 
NERangeKerneloperator= (NERangeKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NERangeKernel ()=default
 Default destructor. More...
 
void configure (ITensor *output, float start, float end, float step)
 Initialize the kernel's output tensor, start, end and step of the sequence. 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...
 
virtual size_t get_mws (const CPUInfo &platform, size_t thread_count) const
 Return minimum workload size of the relevant kernel. 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 *output, float start, float end, float step)
 Static function to check if given info will lead to a valid configuration of NERangeKernel. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ICPPKernel
static constexpr size_t default_mws = 1
 

Detailed Description

Kernel class for Range.

range generates a 1-D tensor containing a sequence of numbers that begins at 'start' and extends by increments of 'step' up to but not including 'end'.

Definition at line 39 of file NERangeKernel.h.

Constructor & Destructor Documentation

◆ NERangeKernel() [1/3]

Default constructor.

Definition at line 141 of file NERangeKernel.cpp.

Referenced by NERangeKernel::name().

142  : _start(0), _end(1), _step(1), _output(nullptr)
143 {
144 }

◆ NERangeKernel() [2/3]

NERangeKernel ( const NERangeKernel )
delete

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

◆ NERangeKernel() [3/3]

NERangeKernel ( NERangeKernel &&  )
default

Allow instances of this class to be moved.

◆ ~NERangeKernel()

~NERangeKernel ( )
default

Default destructor.

Referenced by NERangeKernel::name().

Member Function Documentation

◆ configure()

void configure ( ITensor output,
float  start,
float  end,
float  step 
)

Initialize the kernel's output tensor, start, end and step of the sequence.

Parameters
[out]outputOutput tensor. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]startThe starting value of the sequence.
[in]endThe ending (not including) value of the sequence.
[in]stepThe gap between each pair of values in the sequence.

Definition at line 146 of file NERangeKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ITensorInfo::data_type(), arm_compute::mlgo::parser::end(), ITensor::info(), arm_compute::num_of_elements_in_range(), ITensorInfo::quantization_info(), arm_compute::cpu::step, and arm_compute::cpu::kernels::validate_arguments().

Referenced by NERangeKernel::name().

147 {
149 
150  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*(output->info()), start, end, step));
151 
152  // Auto initialize output if not initialized
153  auto_init_if_empty(*output->info(), TensorShape(num_of_elements_in_range(start, end, step)), 1, output->info()->data_type(), output->info()->quantization_info());
154 
155  // Configure kernel window
156  Window win = calculate_max_window(*output->info(), Steps());
157 
158  _start = start;
159  _end = end;
160  _step = step;
161  _output = output;
162 
163  INEKernel::configure(win);
164 }
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
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
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...
void end(TokenStream &in, bool &valid)
Definition: MLGOParser.cpp:290
size_t num_of_elements_in_range(const float start, const float end, const float step)
Returns the number of elements required to go from start to end with the wanted step.
Definition: Utils.h:1146
constexpr int step
Definition: fp32.cpp:35
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NERangeKernel& operator= ( const NERangeKernel )
delete

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

Referenced by NERangeKernel::name().

◆ operator=() [2/2]

NERangeKernel& operator= ( NERangeKernel &&  )
default

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 175 of file NERangeKernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), ITensor::info(), and IKernel::window().

Referenced by NERangeKernel::name().

176 {
180  const auto *uk = get_implementation(RangeSelectorData{ _output->info()->data_type() });
181 
182  uk->ukernel(_output, _start, _step, window);
183 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#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
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ validate()

Status validate ( const ITensorInfo output,
float  start,
float  end,
float  step 
)
static

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

Parameters
[in]outputOutput tensor info. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]startThe starting value of the sequence.
[in]endThe ending (not including) value of the sequence.
[in]stepThe gap between each pair of values in the sequence.
Returns
a status

Definition at line 166 of file NERangeKernel.cpp.

References ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, and arm_compute::cpu::kernels::validate_arguments().

Referenced by NERangeKernel::name(), and NERange::validate().

167 {
169 
171 
172  return Status{};
173 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
void end(TokenStream &in, bool &valid)
Definition: MLGOParser.cpp:290
constexpr int step
Definition: fp32.cpp:35

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