Compute Library
 22.11
CLCast Class Reference

Basic function to run opencl::kernels::ClCastKernel. More...

#include <CLCast.h>

Collaboration diagram for CLCast:
[legend]

Public Member Functions

 CLCast ()
 Constructor. More...
 
 ~CLCast ()
 Destructor. More...
 
 CLCast (const CLCast &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLCast (CLCast &&)
 Default move constructor. More...
 
CLCastoperator= (const CLCast &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLCastoperator= (CLCast &&)
 Default move assignment operator. More...
 
void configure (const ICLTensor *input, ICLTensor *output, ConvertPolicy policy)
 Initialize the function's source, destination. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, ConvertPolicy policy)
 Initialize the function's source, destination. 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, ConvertPolicy policy)
 Static function to check if given info will lead to a valid configuration of CLCast. More...
 

Detailed Description

Basic function to run opencl::kernels::ClCastKernel.

Definition at line 40 of file CLCast.h.

Constructor & Destructor Documentation

◆ CLCast() [1/3]

CLCast ( )

Constructor.

Definition at line 45 of file CLCast.cpp.

References CLCast::operator=(), and CLCast::~CLCast().

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

◆ ~CLCast()

~CLCast ( )
default

Destructor.

Referenced by CLCast::CLCast().

◆ CLCast() [2/3]

CLCast ( const CLCast )
delete

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

◆ CLCast() [3/3]

CLCast ( CLCast &&  )
default

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const ICLTensor input,
ICLTensor output,
ConvertPolicy  policy 
)

Initialize the function's source, destination.

Valid data layouts:

  • All

Valid data type configurations:

src dst
U8 S8, U16, S16, U32, S32, F16, F32
U16 U8, S8, S16, U32, S32, F16, F32
S16 U8, S8, U16, U32, S32, F16, F32
U32 U8, S8, U16, S16, S32, F16, F32
S32 U8, S8, U16, S16, U32, F16, F32
F16 U8, S8, U16, S16, U32, F32
F32 U8, S8, U16, S16, U32, F16

Input data type must be different than output data type.

Parameters
[in]inputThe input tensor to convert. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[out]outputThe output tensor. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]policyConversion policy.

Definition at line 53 of file CLCast.cpp.

References CLKernelLibrary::get().

54 {
55  configure(CLKernelLibrary::get().get_compile_context(), input, output, policy);
56 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, ConvertPolicy policy)
Initialize the function&#39;s source, destination.
Definition: CLCast.cpp:53

◆ configure() [2/2]

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

Initialize the function's source, destination.

Input data type must be different than output data type.

Valid conversions Input -> Output :

  • U8 -> S8, U16, S16, U32, S32, F16, F32
  • U16 -> U8, S8, S16, U32, S32, F16, F32
  • S16 -> U8, S8, U16, U32, S32, F16, F32
  • U32 -> U8, S8, U16, S16, S32, F16, F32
  • S32 -> U8, S8, U16, S16, U32, F16, F32
  • F16 -> U8, S8, U16, S16, U32, F32
  • F32 -> U8, S8, U16, S16, U32, F16
Parameters
[in]compile_contextThe compile context to be used.
[in]inputThe input tensor to convert. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[out]outputThe output tensor. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]policyConversion policy.

Definition at line 58 of file CLCast.cpp.

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

59 {
61  ARM_COMPUTE_LOG_PARAMS(input, output, policy);
62 
63  _impl->src = input;
64  _impl->dst = output;
65 
66  _impl->op = std::make_unique<opencl::ClCast>();
67  _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), policy);
68 }
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ operator=() [1/2]

CLCast& operator= ( const CLCast )
delete

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

Referenced by CLCast::CLCast().

◆ operator=() [2/2]

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

References arm_compute::ACL_DST, arm_compute::ACL_SRC, and arm_compute::test::validation::pack.

76 {
77  ITensorPack pack = { { ACL_SRC, _impl->src }, { ACL_DST, _impl->dst } };
78  _impl->op->run(pack);
79 }

◆ validate()

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

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

Parameters
[in]inputSource tensor info. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]outputDestination tensor info. Data type supported: U8/S8/U16/S16/U32/S32/F16/F32.
[in]policyConversion policy.
Returns
a status

Definition at line 70 of file CLCast.cpp.

References ClCast::validate().

71 {
72  return opencl::ClCast::validate(input, output, policy);
73 }
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, ConvertPolicy policy)
Static function to check if given info will lead to a valid configuration.
Definition: ClCast.cpp:43

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