Compute Library
 21.08
CLConvertFullyConnectedWeights Class Reference

Basic function to run an opencl::kernels::ClConvertFullyConnectedWeightsKernel. More...

#include <CLConvertFullyConnectedWeights.h>

Collaboration diagram for CLConvertFullyConnectedWeights:
[legend]

Public Member Functions

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

Detailed Description

Constructor & Destructor Documentation

◆ CLConvertFullyConnectedWeights() [1/3]

Constructor.

Definition at line 41 of file CLConvertFullyConnectedWeights.cpp.

References CLConvertFullyConnectedWeights::~CLConvertFullyConnectedWeights().

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

◆ ~CLConvertFullyConnectedWeights()

◆ CLConvertFullyConnectedWeights() [2/3]

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

◆ CLConvertFullyConnectedWeights() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output,
const TensorShape original_input_shape,
DataLayout  data_layout 
)

Initialize the function.

Valid data layouts:

  • NHWC
  • NCHW

Valid data type configurations:

src dst
All All
Parameters
[in]inputSource weights tensor to convert. Must be 2 dimensional. Data types supported: All.
[out]outputThe converted weights tensor. Shape and Data Type: Same as input.
[in]original_input_shapeShape of the original input tensor (the one entering fully connected layer).
[in]data_layoutThe data layout the weights have been trained in.
Returns
A status

Definition at line 47 of file CLConvertFullyConnectedWeights.cpp.

References CLKernelLibrary::get().

Referenced by CLConvertFullyConnectedWeightsManaged::configure().

49 {
50  configure(CLKernelLibrary::get().get_compile_context(), input, output, original_input_shape, data_layout);
51 }
const DataLayout data_layout
Definition: Im2Col.cpp:151
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, const TensorShape &original_input_shape, DataLayout data_layout)
Initialize the function.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output,
const TensorShape original_input_shape,
DataLayout  data_layout 
)

Initialize the function.

Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource weights tensor to convert. Must be 2 dimensional. Data types supported: All.
[out]outputThe converted weights tensor. Shape and Data Type: Same as input.
[in]original_input_shapeShape of the original input tensor (the one entering fully connected layer).
[in]data_layoutThe data layout the weights have been trained in.
Returns
A status

Definition at line 53 of file CLConvertFullyConnectedWeights.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, arm_compute::test::validation::data_layout, and arm_compute::test::validation::input.

55 {
57  _impl->src = input;
58  _impl->dst = output;
59  _impl->op = std::make_unique<opencl::ClConvertFullyConnectedWeights>();
60  _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), original_input_shape, data_layout);
61 }
const DataLayout data_layout
Definition: Im2Col.cpp:151
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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 69 of file CLConvertFullyConnectedWeights.cpp.

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

70 {
71  ITensorPack pack;
72  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
73  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
74  _impl->op->run(pack);
75 }
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const TensorShape original_input_shape,
DataLayout  data_layout 
)
static

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

Parameters
[in]inputSource weights tensor info to convert. Must be 2 dimensional. Data types supported: All.
[in]outputThe converted weights tensor info. Shape and Data Type: Same as input.
[in]original_input_shapeShape of the original input tensor (the one entering fully connected layer).
[in]data_layoutThe data layout the weights have been trained in.

Definition at line 63 of file CLConvertFullyConnectedWeights.cpp.

References ClConvertFullyConnectedWeights::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

65 {
66  return opencl::ClConvertFullyConnectedWeights::validate(input, output, original_input_shape, data_layout);
67 }
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const TensorShape &original_src_shape, DataLayout data_layout)
Static function to check if given info will lead to a valid configuration.
const DataLayout data_layout
Definition: Im2Col.cpp:151

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