Compute Library
 21.02
CpuPoolingAssemblyDispatch Class Reference

Basic function to run pooling assembly kernels. More...

#include <CpuPoolingAssemblyDispatch.h>

Collaboration diagram for CpuPoolingAssemblyDispatch:
[legend]

Public Member Functions

 CpuPoolingAssemblyDispatch (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Constructor. More...
 
 CpuPoolingAssemblyDispatch (const CpuPoolingAssemblyDispatch &)=delete
 Prevent instances of this class from being copied. More...
 
 CpuPoolingAssemblyDispatch (CpuPoolingAssemblyDispatch &&)=default
 Default move constructor. More...
 
CpuPoolingAssemblyDispatchoperator= (const CpuPoolingAssemblyDispatch &)=delete
 Prevent instances of this class from being copied. More...
 
CpuPoolingAssemblyDispatchoperator= (CpuPoolingAssemblyDispatch &&)=default
 Default move assignment operator. More...
 
 ~CpuPoolingAssemblyDispatch ()
 Destructor. More...
 
void configure (const ITensorInfo *src, ITensorInfo *dst, const PoolingLayerInfo &info)
 If supported create an assembly routine, else fallback to Compute Library function. More...
 
bool is_configured () const
 Was the function successfully configured ? 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 *src, const ITensorInfo *dst, const PoolingLayerInfo &info)
 Indicates whether or not this function can be used to process the given parameters. More...
 

Detailed Description

Basic function to run pooling assembly kernels.

Definition at line 40 of file CpuPoolingAssemblyDispatch.h.

Constructor & Destructor Documentation

◆ CpuPoolingAssemblyDispatch() [1/3]

CpuPoolingAssemblyDispatch ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Constructor.

Definition at line 35 of file CpuPoolingAssemblyDispatch.cpp.

36  : _memory_group(std::move(memory_manager)),
37  _workspace(),
38  _is_global_pooling_layer(false)
39 {
40 }

◆ CpuPoolingAssemblyDispatch() [2/3]

Prevent instances of this class from being copied.

◆ CpuPoolingAssemblyDispatch() [3/3]

Default move constructor.

◆ ~CpuPoolingAssemblyDispatch()

Destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensorInfo src,
ITensorInfo dst,
const PoolingLayerInfo info 
)

If supported create an assembly routine, else fallback to Compute Library function.

Parameters
[in]srcSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[out]dstDestination tensor info to store the result of pooling. Data types supported: same as src.
[in]infoPooling meta-data

Definition at line 44 of file CpuPoolingAssemblyDispatch.cpp.

References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON, IScheduler::cpu_info(), ITensorInfo::dimension(), Scheduler::get(), Size2D::height, TensorAllocator::init(), MemoryGroup::manage(), IScheduler::num_threads(), PoolingLayerInfo::pool_size, arm_compute::S8, CpuPoolingAssemblyDispatch::validate(), and Size2D::width.

45 {
46  const CPUInfo &ci = NEScheduler::get().cpu_info();
47  const unsigned int num_threads = NEScheduler::get().num_threads();
48 
49  // If we don't support a combination of data types, silently return: it is the caller's responsibility to check if configure() was successful via is_configured()
51  {
52  return;
53  }
54 
55  auto pooling_wrapper = std::make_unique<kernels::CpuPoolingAssemblyWrapperKernel>();
56  ARM_COMPUTE_ERROR_ON(pooling_wrapper == nullptr);
57  pooling_wrapper->configure(src, dst, info, ci);
58 
59  // Check if we have Global Pooling Layer
60  _is_global_pooling_layer = (src->dimension(2) == info.pool_size.width) && (src->dimension(1) == info.pool_size.height);
61 
62  // Allocate workspace based on kernel's memory requirements
63  constexpr size_t alignment = 4096;
64  const size_t workspace_size = pooling_wrapper->get_working_size(num_threads);
65  _workspace.allocator()->init(TensorInfo(TensorShape{ (workspace_size + alignment /* FIXME: remove alignment after COMPMID-1088 */) }, 1, DataType::S8), alignment);
66  _memory_group.manage(&_workspace);
67  _workspace.allocator()->allocate();
68 
69  _kernel = std::move(pooling_wrapper);
70 }
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &info)
Indicates whether or not this function can be used to process the given parameters.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
CPUInfo & cpu_info()
Get CPU info.
Definition: IScheduler.cpp:42
SimpleTensor< float > src
Definition: DFT.cpp:155
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
virtual unsigned int num_threads() const =0
Returns the number of threads that the SingleThreadScheduler has in his pool.
signed 8-bit number
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ is_configured()

bool is_configured ( ) const

Was the function successfully configured ?

Returns
True if the function is configured and ready to run

Definition at line 77 of file CpuPoolingAssemblyDispatch.cpp.

78 {
79  return _kernel != nullptr;
80 }

◆ operator=() [1/2]

CpuPoolingAssemblyDispatch& operator= ( const CpuPoolingAssemblyDispatch )
delete

Prevent instances of this class from being copied.

◆ operator=() [2/2]

Default move assignment operator.

◆ 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 82 of file CpuPoolingAssemblyDispatch.cpp.

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

83 {
84  ARM_COMPUTE_ERROR_ON_MSG(tensors.empty(), "No srcs provided");
85 
86  tensors.add_tensor(TensorType::ACL_DST_1, &_workspace);
87 
88  if(_is_global_pooling_layer)
89  {
90  NEScheduler::get().schedule_op(_kernel.get(), Window::DimX, _kernel->window(), tensors);
91  }
92  else
93  {
94  NEScheduler::get().schedule_op(_kernel.get(), Window::DimY, _kernel->window(), tensors);
95  }
96 }
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.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#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 src,
const ITensorInfo dst,
const PoolingLayerInfo info 
)
static

Indicates whether or not this function can be used to process the given parameters.

Parameters
[in]srcSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]dstDestination tensor to store the result of pooling. Data types supported: same as src.
[in]infoPooling meta-data
Returns
a status.

Definition at line 72 of file CpuPoolingAssemblyDispatch.cpp.

References CpuPoolingAssemblyWrapperKernel::validate().

Referenced by CpuPoolingAssemblyDispatch::configure(), CpuPooling::configure(), and CpuPooling::validate().

73 {
75 }
SimpleTensor< float > src
Definition: DFT.cpp:155
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &info)
Indicates whether or not this function can be used to process the given parameters.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

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