Compute Library
 24.04
NEMatMul Class Reference

Basic function to run the following operators: More...

#include <NEMatMul.h>

Collaboration diagram for NEMatMul:
[legend]

Public Member Functions

 NEMatMul ()
 Constructor. More...
 
 ~NEMatMul ()
 Destructor. More...
 
 NEMatMul (const NEMatMul &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEMatMul (NEMatMul &&)=default
 Default move constructor. More...
 
NEMatMuloperator= (const NEMatMul &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEMatMuloperator= (NEMatMul &&)=default
 Default move assignment operator. More...
 
void configure (ITensor *lhs, ITensor *rhs, ITensor *dst, const MatMulInfo &info, const CpuMatMulSettings &settings, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Initialize. 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 *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration of NEMatMul. More...
 

Detailed Description

Basic function to run the following operators:

  1. cpu::CpuMatMul

Definition at line 77 of file NEMatMul.h.

Constructor & Destructor Documentation

◆ NEMatMul() [1/3]

NEMatMul ( )

Constructor.

Definition at line 46 of file NEMatMul.cpp.

46  : _impl(std::make_unique<Impl>())
47 {
48 }

◆ ~NEMatMul()

~NEMatMul ( )
default

Destructor.

◆ NEMatMul() [2/3]

NEMatMul ( const NEMatMul )
delete

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

◆ NEMatMul() [3/3]

NEMatMul ( NEMatMul &&  )
default

Default move constructor.

Member Function Documentation

◆ configure()

void configure ( ITensor lhs,
ITensor rhs,
ITensor dst,
const MatMulInfo info,
const CpuMatMulSettings settings,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Initialize.

Valid data layouts:

  • Any

Valid data type configurations:

lhs rhs dst
F32 F32 F32
F16 F16 F16
BFLOAT16 BFLOAT16 BFLOAT16
QASYMM8_SIGNED QASYMM8_SIGNED QASYMM8_SIGNED
QASYMM8 QASYMM8 QASYMM8
Parameters
[in]lhsLeft-hand side tensor info. Data types supported: F16/F32/QASYMM8_SIGNED/QASYMM8.
[in]rhsRight-hand side tensor info. Data types supported: same as lhs.
[out]dstOutput tensor to store the result of the batched matrix multiplication. Data types supported: same as lhs / rhs.
[in]infoContains MatMul operation information described in MatMulInfo.
[in]settingsContains flags for function level settings i.e fast math
[in]act_info(Optional) Contains activation function and lower and upper bound values for bounded activation functions.

Definition at line 52 of file NEMatMul.cpp.

58 {
59  _impl->lhs = lhs;
60  _impl->rhs = rhs;
61  _impl->output = output;
62 
63  ARM_COMPUTE_ERROR_ON_NULLPTR(_impl->lhs, _impl->rhs, _impl->output);
64  _impl->op = std::make_unique<cpu::CpuMatMul>();
65  _impl->op->configure(lhs->info(), rhs->info(), output->info(), info, settings, act_info);
66  _impl->run_pack = {{ACL_SRC_0, lhs}, {ACL_SRC_1, rhs}, {ACL_DST, output}};
67  _impl->workspace_tensors = manage_workspace<Tensor>(_impl->op->workspace(), _impl->memory_group, _impl->run_pack);
68 }

References arm_compute::ACL_DST, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR_ON_NULLPTR, ITensor::info(), and arm_compute::test::validation::info.

◆ operator=() [1/2]

NEMatMul& operator= ( const NEMatMul )
delete

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

◆ operator=() [2/2]

NEMatMul& operator= ( NEMatMul &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For CPU 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 80 of file NEMatMul.cpp.

81 {
82  MemoryGroupResourceScope scope_mg(_impl->memory_group);
83  _impl->op->run(_impl->run_pack);
84 }

◆ validate()

Status validate ( const ITensorInfo lhs,
const ITensorInfo rhs,
const ITensorInfo dst,
const MatMulInfo info,
const CpuMatMulSettings settings,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)
static

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

Parameters
[in]lhsLeft-hand side tensor info. Data types supported: F16/F32/QASYMM8_SIGNED/QASYMM8.
[in]rhsRight-hand side tensor info. Data types supported: same as lhs.
[out]dstOutput tensor info to store the result of the batched matrix multiplication. Data types supported: same as lhs / rhs.
[in]infoContains MatMul operation information described in MatMulInfo.
[in]settingsContains flags for function level settings i.e fast math
[in]act_info(Optional) Contains activation function and lower and upper bound values for bounded activation functions.
Returns
Status

Definition at line 70 of file NEMatMul.cpp.

76 {
77  return cpu::CpuMatMul::validate(lhs, rhs, output, info, settings, act_info);
78 }

References arm_compute::test::validation::act_info, arm_compute::test::validation::info, and CpuMatMul::validate().


The documentation for this class was generated from the following files:
arm_compute::cpu::CpuMatMul::validate
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: CpuMatMul.cpp:97
arm_compute::ACL_SRC_0
@ ACL_SRC_0
Definition: Types.h:45
arm_compute::ACL_SRC_1
@ ACL_SRC_1
Definition: Types.h:46
arm_compute::test::validation::act_info
act_info
Definition: DirectConvolutionLayer.cpp:547
ARM_COMPUTE_ERROR_ON_NULLPTR
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
arm_compute::ACL_DST
@ ACL_DST
Definition: Types.h:55
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)