Compute Library
 21.02
NEElementwiseDivision Class Reference

Basic function to run cpu::kernels::CpuArithmeticKernel for division. More...

#include <NEElementwiseOperations.h>

Collaboration diagram for NEElementwiseDivision:
[legend]

Public Member Functions

 NEElementwiseDivision ()
 Default Constructor. More...
 
 ~NEElementwiseDivision ()
 Default Destructor. More...
 
 NEElementwiseDivision (const NEElementwiseDivision &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEElementwiseDivision (NEElementwiseDivision &&)
 Default move constructor. More...
 
NEElementwiseDivisionoperator= (const NEElementwiseDivision &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEElementwiseDivisionoperator= (NEElementwiseDivision &&)
 Default move assignment operator. More...
 
void configure (ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Initialise the kernel's inputs, output and conversion policy. 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...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for division. More...
 

Detailed Description

Basic function to run cpu::kernels::CpuArithmeticKernel for division.

Note
The tensor data type for the inputs must be F16/F32.
The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])

Definition at line 181 of file NEElementwiseOperations.h.

Constructor & Destructor Documentation

◆ NEElementwiseDivision() [1/3]

Default Constructor.

Definition at line 165 of file NEElementwiseOperations.cpp.

References NEElementwiseDivision::operator=(), and NEElementwiseDivision::~NEElementwiseDivision().

166  : _impl(std::make_unique<Impl>())
167 {
168 }

◆ ~NEElementwiseDivision()

~NEElementwiseDivision ( )
default

Default Destructor.

Referenced by NEElementwiseDivision::NEElementwiseDivision().

◆ NEElementwiseDivision() [2/3]

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

◆ NEElementwiseDivision() [3/3]

Default move constructor.

Member Function Documentation

◆ configure()

void configure ( ITensor input1,
ITensor input2,
ITensor output,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Initialise the kernel's inputs, output and conversion policy.

Parameters
[in,out]input1First tensor input. Data types supported: F16/F32.
[in,out]input2Second tensor input. Data types supported: Same as input1.
[out]outputOutput tensor. Data types supported: Same as input1.
[in]act_info(Optional) Activation layer information in case of a fused activation. Currently not supported.

Definition at line 173 of file NEElementwiseOperations.cpp.

References ARM_COMPUTE_UNUSED, and ITensor::info().

174 {
175  ARM_COMPUTE_UNUSED(act_info);
176  _impl->src_0 = input1;
177  _impl->src_1 = input2;
178  _impl->dst = output;
179  _impl->op = std::make_unique<cpu::CpuElementwiseDivision>();
180  _impl->op->configure(input1->info(), input2->info(), output->info());
181 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ operator=() [1/2]

NEElementwiseDivision& operator= ( const NEElementwiseDivision )
delete

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

Referenced by NEElementwiseDivision::NEElementwiseDivision().

◆ operator=() [2/2]

NEElementwiseDivision & operator= ( NEElementwiseDivision &&  )
default

Default move assignment operator.

◆ 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 189 of file NEElementwiseOperations.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ITensorPack::add_tensor(), and arm_compute::test::validation::dst.

190 {
191  ITensorPack pack;
192  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
193  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
194  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
195  _impl->op->run(pack);
196 }

◆ validate()

Status validate ( const ITensorInfo input1,
const ITensorInfo input2,
const ITensorInfo output,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)
static

Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for division.

Parameters
[in]input1First tensor input info. Data types supported: F16/F32.
[in]input2Second tensor input info. Data types supported: Same as input1.
[in]outputOutput tensor info. Data types supported: Same as input1.
[in]act_info(Optional) Activation layer information in case of a fused activation. Currently not supported.
Returns
a status

Definition at line 183 of file NEElementwiseOperations.cpp.

References ARM_COMPUTE_RETURN_ERROR_ON, ActivationLayerInfo::enabled(), and CpuElementwiseDivision::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

184 {
185  ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled());
186  return cpu::CpuElementwiseDivision::validate(input1, input2, output);
187 }
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithme...

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