Compute Library
 22.08
CpuDirectConv3d Class Reference

Function to run the direct convolution. More...

#include <CpuDirectConv3d.h>

Collaboration diagram for CpuDirectConv3d:
[legend]

Public Member Functions

 CpuDirectConv3d (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 
 ~CpuDirectConv3d ()
 
void configure (ITensorInfo *src0, ITensorInfo *src1, const ITensorInfo *src2, ITensorInfo *dst, const Conv3dInfo conv_info)
 Set the input, weights, biases and output tensor info. 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 *src0, const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const Conv3dInfo conv_info)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Function to run the direct convolution.

This function calls the following kernels:

  1. kernels::CpuDirectConv3dKernel

Definition at line 53 of file CpuDirectConv3d.h.

Constructor & Destructor Documentation

◆ CpuDirectConv3d()

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

Definition at line 38 of file CpuDirectConv3d.cpp.

39  : _memory_group(std::move(memory_manager)), _conv_kernel(), _activationlayer_function(), _accumulator(), _is_activationlayer_enabled(false), _dim_split(Window::DimZ)
40 {
41 }
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47

◆ ~CpuDirectConv3d()

~CpuDirectConv3d ( )
default

Member Function Documentation

◆ configure()

void configure ( ITensorInfo src0,
ITensorInfo src1,
const ITensorInfo src2,
ITensorInfo dst,
const Conv3dInfo  conv_info 
)

Set the input, weights, biases and output tensor info.

Valid data layouts:

  • NDHWC

Valid data type configurations:

src0 src1 src2 dst
F16 F16 F16 F16
F32 F32 F32 F32
QASYMM8 QASYMM8 S32 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED S32 QASYMM8_SIGNED
Parameters
[in,out]src0Input tensor info.
[in]src1Set of kernels to convolve the input volume. The 2nd dimension must be the same as the src0's volume 1st dimension.
[in]src2Set of biases. Can be nullptr.
[out]dstOutput tensor info. The 1st dimensions must be equal to the 1st dimension of the kernels tensor.
[in]conv_infoContains padding, stride, acitvation information.

Definition at line 43 of file CpuDirectConv3d.cpp.

References Conv3dInfo::act_info, Tensor::allocator(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_LOG_PARAMS, Tensor::buffer(), ITensorInfo::data_layout(), Window::DimY, ActivationLayerInfo::enabled(), TensorAllocator::free(), and arm_compute::NDHWC.

44 {
45  ARM_COMPUTE_LOG_PARAMS(src0, src1, src2, dst, conv_info);
46  ARM_COMPUTE_ERROR_ON(src0->data_layout() != DataLayout::NDHWC);
47 
48  _conv_kernel = std::make_unique<kernels::CpuDirectConv3dKernel>();
49 
50  // Free accumulator
51  if(_accumulator.buffer() != nullptr)
52  {
53  _accumulator.allocator()->free();
54  }
55 
56  _dim_split = Window::DimY;
57 
58  _conv_kernel->configure(src0, src1, src2, dst, conv_info);
59 
60  //Configure Activation Layer
61  _is_activationlayer_enabled = conv_info.act_info.enabled();
62  if(_is_activationlayer_enabled)
63  {
64  _activationlayer_function = std::make_unique<CpuActivation>();
65  _activationlayer_function->configure(dst, dst, conv_info.act_info);
66  }
67 }
#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
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void free() override
Free allocated CPU memory.
Num samples, depth, height, width, channels.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
uint8_t * buffer() const override
Interface to be implemented by the child class to return a pointer to CPU memory. ...
Definition: Tensor.cpp:43
#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 84 of file CpuDirectConv3d.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, ITensorPack::add_tensor(), arm_compute::test::validation::dst, Scheduler::get(), ITensorPack::get_tensor(), arm_compute::test::validation::pack, and IScheduler::schedule_op().

85 {
86  MemoryGroupResourceScope scope_mg(_memory_group);
87 
88  auto dst = tensors.get_tensor(TensorType::ACL_DST);
89 
90  NEScheduler::get().schedule_op(_conv_kernel.get(), _dim_split, _conv_kernel->window(), tensors);
91 
92  if(_is_activationlayer_enabled)
93  {
94  ITensorPack pack;
96  pack.add_tensor(TensorType::ACL_DST, dst);
97  _activationlayer_function->run(pack);
98  }
99 }
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.
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ validate()

Status validate ( const ITensorInfo src0,
const ITensorInfo src1,
const ITensorInfo src2,
const ITensorInfo dst,
const Conv3dInfo  conv_info 
)
static

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

Similar to CpuDirectConv3d::configure()

Returns
a status

Definition at line 69 of file CpuDirectConv3d.cpp.

References Conv3dInfo::act_info, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ActivationLayerInfo::enabled(), CpuActivation::validate(), and CpuDirectConv3dKernel::validate().

Referenced by NEConv3D::configure(), and NEConv3D::validate().

70 {
72 
73  // Validate Convolution kernel
75 
76  if(conv_info.act_info.enabled())
77  {
79  }
80 
81  return Status{};
82 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const Conv3dInfo &conv_info)
Static function to check if given info will lead to a valid configuration.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Static function to check if given info will lead to a valid configuration.

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