Compute Library
 22.08
CpuMul Class Reference

Basic function to run kernels::CpuMulKernel. More...

#include <CpuMul.h>

Collaboration diagram for CpuMul:
[legend]

Public Member Functions

void configure (ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Initialise the kernel's inputs, dst and convertion policy. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from INEOperator
 INEOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 INEOperator (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEOperator (INEOperator &&)=default
 Default move constructor. More...
 
INEOperatoroperator= (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEOperatoroperator= (INEOperator &&)=default
 Default move assignment operator. More...
 
 ~INEOperator ()
 Default destructor. More...
 
void prepare (ITensorPack &constants) override
 Prepare the function for executing. More...
 
MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Basic function to run kernels::CpuMulKernel.

Definition at line 35 of file CpuMul.h.

Member Function Documentation

◆ configure()

void configure ( ITensorInfo src1,
ITensorInfo src2,
ITensorInfo dst,
float  scale,
ConvertPolicy  overflow_policy,
RoundingPolicy  rounding_policy,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Initialise the kernel's inputs, dst and convertion policy.

Note
For scale equal to 1/255 only round to nearest even (implemented as round half up) is supported. For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
Parameters
[in,out]src1First input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/S32/QSYMM16/F16/F32 This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[in,out]src2Second input tensor info. Data types supported: U8, QASYMM8 (only if src1 is QASYMM8), QASYMM8_SIGNED (only if src1 is QASYMM8_SIGNED), S16, S32, QSYMM16 (only if src1 is QSYMM16), F16 (only if src1 is F16), F32 (only if src1 is F32). This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[out]dstdst tensor info. Data types supported:
  • U8, only if both inputs are U8.
  • QASYMM8, only if both inputs are QASYMM8.
  • QASYMM8_SIGNED, only if src1 is QASYMM8_SIGNED.
  • S16.
  • QSYMM16, only if both inputs are QSYMM16.
  • S32, only if both inputs are S32 or both are QSYMM16.
  • F16, only if src1 is F16.
  • F32, only if both inputs are F32.
[in]scaleScale to apply after multiplication. Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15. If both src1, src2 and dst are of datatype S32, scale cannot be 1/255
[in]overflow_policyOverflow policy. ConvertPolicy cannot be WRAP if any of the inputs is of quantized datatype
[in]rounding_policyRounding policy.
[in]act_info(Optional) Activation layer information in case of a fused activation. Currently not supported.

Definition at line 43 of file CpuMul.cpp.

References ARM_COMPUTE_LOG_PARAMS, ARM_COMPUTE_UNUSED, and arm_compute::test::validation::k.

45 {
46  ARM_COMPUTE_UNUSED(act_info);
47  ARM_COMPUTE_LOG_PARAMS(src1, src2, dst, scale, overflow_policy, rounding_policy, act_info);
48 
49  auto k = std::make_unique<kernels::CpuMulKernel>();
50  k->configure(src1, src2, dst, scale, overflow_policy, rounding_policy);
51  _kernel = std::move(k);
52 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_LOG_PARAMS(...)

◆ run()

void run ( ITensorPack tensors)
overridevirtual

Run the kernels contained in the function.

Parameters
[in]tensorsVector that contains the tensors to operate on.

Reimplemented from INEOperator.

Definition at line 54 of file CpuMul.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, Window::DimY, ITensorPack::empty(), Scheduler::get(), and IScheduler::schedule_op().

55 {
56  ARM_COMPUTE_ERROR_ON_MSG(tensors.empty(), "No inputs provided");
57  NEScheduler::get().schedule_op(_kernel.get(), Window::DimY, _kernel->window(), tensors);
58 }
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ validate()

Status validate ( const ITensorInfo src1,
const ITensorInfo src2,
const ITensorInfo dst,
float  scale,
ConvertPolicy  overflow_policy,
RoundingPolicy  rounding_policy,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)
static

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

Similar to CpuMul::configure()

Returns
a status

Definition at line 36 of file CpuMul.cpp.

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

Referenced by NEPixelWiseMultiplication::validate().

38 {
39  ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled());
40  return kernels::CpuMulKernel::validate(src1, src2, dst, scale, overflow_policy, rounding_policy);
41 }
#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 *src1, const ITensorInfo *src2, const ITensorInfo *dst, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy)
Static function to check if given info will lead to a valid configuration.

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