Compute Library
 21.02
NEElementwiseSquaredDiff Class Reference

Basic function to run cpu::kernels::CpuArithmeticKernel for squared difference. More...

#include <NEElementwiseOperations.h>

Collaboration diagram for NEElementwiseSquaredDiff:
[legend]

Public Member Functions

 NEElementwiseSquaredDiff ()
 Default Constructor. More...
 
 ~NEElementwiseSquaredDiff ()
 Default Destructor. More...
 
 NEElementwiseSquaredDiff (const NEElementwiseSquaredDiff &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEElementwiseSquaredDiff (NEElementwiseSquaredDiff &&)
 Default move constructor. More...
 
NEElementwiseSquaredDiffoperator= (const NEElementwiseSquaredDiff &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEElementwiseSquaredDiffoperator= (NEElementwiseSquaredDiff &&)
 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 squared difference. More...
 

Detailed Description

Basic function to run cpu::kernels::CpuArithmeticKernel for squared difference.

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

Definition at line 134 of file NEElementwiseOperations.h.

Constructor & Destructor Documentation

◆ NEElementwiseSquaredDiff() [1/3]

Default Constructor.

Definition at line 124 of file NEElementwiseOperations.cpp.

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

125  : _impl(std::make_unique<Impl>())
126 {
127 }

◆ ~NEElementwiseSquaredDiff()

Default Destructor.

Referenced by NEElementwiseSquaredDiff::NEElementwiseSquaredDiff().

◆ NEElementwiseSquaredDiff() [2/3]

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

◆ NEElementwiseSquaredDiff() [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: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/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 132 of file NEElementwiseOperations.cpp.

References ARM_COMPUTE_UNUSED, and ITensor::info().

133 {
134  ARM_COMPUTE_UNUSED(act_info);
135  _impl->src_0 = input1;
136  _impl->src_1 = input2;
137  _impl->dst = output;
138  _impl->op = std::make_unique<cpu::CpuElementwiseSquaredDiff>();
139  _impl->op->configure(input1->info(), input2->info(), output->info());
140 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ operator=() [1/2]

NEElementwiseSquaredDiff& operator= ( const NEElementwiseSquaredDiff )
delete

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

Referenced by NEElementwiseSquaredDiff::NEElementwiseSquaredDiff().

◆ operator=() [2/2]

NEElementwiseSquaredDiff & operator= ( NEElementwiseSquaredDiff &&  )
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 148 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.

149 {
150  ITensorPack pack;
151  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
152  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
153  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
154  _impl->op->run(pack);
155 }

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

Parameters
[in]input1First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/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 142 of file NEElementwiseOperations.cpp.

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

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

143 {
144  ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled());
145  return cpu::CpuElementwiseSquaredDiff::validate(input1, input2, output);
146 }
#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: