Compute Library
 21.05
CLQuantizationLayer Class Reference

Basic function to simulate a quantization layer. More...

#include <CLQuantizationLayer.h>

Collaboration diagram for CLQuantizationLayer:
[legend]

Public Member Functions

 CLQuantizationLayer ()
 Default Constructor. More...
 
 ~CLQuantizationLayer ()
 Default Destructor. More...
 
 CLQuantizationLayer (const CLQuantizationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLQuantizationLayer (CLQuantizationLayer &&)=default
 Default move constructor. More...
 
CLQuantizationLayeroperator= (const CLQuantizationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLQuantizationLayeroperator= (CLQuantizationLayer &&)=default
 Default move assignment operator. More...
 
void configure (const ICLTensor *input, ICLTensor *output)
 Set the input and output tensors. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
 Set the input and output tensors. 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 *input, const ITensorInfo *output)
 Static function to check if given info will lead to a valid configuration of CLQuantizationLayer. More...
 

Detailed Description

Basic function to simulate a quantization layer.

This function calls the following CL kernels:

  1. opencl::ClQuantization
Note
The implementation supports only 3D input tensors.

Definition at line 45 of file CLQuantizationLayer.h.

Constructor & Destructor Documentation

◆ CLQuantizationLayer() [1/3]

Default Constructor.

Definition at line 40 of file CLQuantizationLayer.cpp.

41  : _impl(std::make_unique<Impl>())
42 {
43 }

◆ ~CLQuantizationLayer()

~CLQuantizationLayer ( )
default

Default Destructor.

◆ CLQuantizationLayer() [2/3]

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

◆ CLQuantizationLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output 
)

Set the input and output tensors.

Valid data layouts:

  • All

Valid data type configurations:

src dst
QASYMM8 QASYMM8, QASYMM8_SIGNED, QASYMM16
QASYMM8_SIGNED QASYMM8, QASYMM8_SIGNED, QASYMM16
F16 QASYMM8, QASYMM8_SIGNED, QASYMM16
F32 QASYMM8, QASYMM8_SIGNED, QASYMM16
Parameters
[in]inputSource tensor. The dimensions over the third will be interpreted as batches. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/32.
[out]outputDestination tensor with the same dimensions of input. Data types supported: QASYMM8/QASYMM8_SIGNED/QASYMM16.
Note
Output auto initialization is not supported by this function

Definition at line 46 of file CLQuantizationLayer.cpp.

47 {
48  configure(CLKernelLibrary::get().get_compile_context(), input, output);
49 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output)
Set the input and output tensors.

References CLKernelLibrary::get(), and arm_compute::test::validation::input.

Referenced by CLReduceMean::configure(), and CLLSTMLayerQuantized::configure().

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output 
)

Set the input and output tensors.

Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. The dimensions over the third will be interpreted as batches. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/32.
[out]outputDestination tensor with the same dimensions of input. Data types supported: QASYMM8/QASYMM8_SIGNED/QASYMM16.
Note
Output auto initialization is not supported by this function

Definition at line 51 of file CLQuantizationLayer.cpp.

52 {
53  _impl->src = input;
54  _impl->dst = output;
55 
56  _impl->op = std::make_unique<opencl::ClQuantization>();
57  _impl->op->configure(compile_context, input->info(), output->info());
58 }

References ITensor::info(), and arm_compute::test::validation::input.

◆ operator=() [1/2]

CLQuantizationLayer& operator= ( const CLQuantizationLayer )
delete

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

◆ operator=() [2/2]

CLQuantizationLayer& operator= ( CLQuantizationLayer &&  )
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 65 of file CLQuantizationLayer.cpp.

66 {
67  ITensorPack pack;
68  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
69  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
70  _impl->op->run(pack);
71 }

References arm_compute::ACL_DST, arm_compute::ACL_SRC, and ITensorPack::add_tensor().

Referenced by CLReduceMean::run(), and CLLSTMLayerQuantized::run().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output 
)
static

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

Parameters
[in]inputInput tensor info. The dimensions over the third will be interpreted as batches. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/32.
[in]outputOutput tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/QASYMM16.
Returns
a status

Definition at line 60 of file CLQuantizationLayer.cpp.

61 {
63 }
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of CLQuantizationLayer.

References arm_compute::test::validation::input, and ClQuantization::validate().

Referenced by CLGenerateProposalsLayer::validate(), and CLLSTMLayerQuantized::validate().


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