Compute Library
CpuContext Class Referencefinal

CPU context implementation class. More...

#include <CpuContext.h>

Collaboration diagram for CpuContext:

Public Member Functions

 CpuContext (const AclContextOptions *options)
 Default Constructor. More...
const CpuCapabilitiescapabilities () const
 Cpu Capabilities accessor. More...
AllocatorWrapperallocator ()
 Backing memory allocator accessor. More...
ITensorV2create_tensor (const AclTensorDescriptor &desc, bool allocate) override
 Create a tensor object. More...
IQueuecreate_queue (const AclQueueOptions *options) override
 Create a queue object. More...
std::tuple< IOperator *, StatusCodecreate_activation (const AclTensorDescriptor &src, const AclTensorDescriptor &dst, const AclActivationDescriptor &act, bool is_validate) override
- Public Member Functions inherited from IContext
 IContext (Target target)
virtual ~IContext ()
 Virtual Destructor. More...
Target type () const
 Target type accessor. More...
void inc_ref () const
 Increment context refcount. More...
void dec_ref () const
 Decrement context refcount. More...
int refcount () const
 Reference counter accessor. More...
bool is_valid () const
 Checks if an object is valid. More...

Additional Inherited Members

- Data Fields inherited from AclContext_
arm_compute::detail::Header header { arm_compute::detail::ObjectType::Context, nullptr }

Detailed Description

CPU context implementation class.

Definition at line 43 of file CpuContext.h.

Constructor & Destructor Documentation

◆ CpuContext()

CpuContext ( const AclContextOptions options)

Default Constructor.

[in]optionsCreational options

Definition at line 149 of file CpuContext.cpp.

References AclContextOptions::allocator, AclContextOptions::capabilities, and AclContextOptions::max_compute_units.

151  _allocator(default_allocator),
152  _caps(populate_capabilities(AclCpuCapabilitiesAuto, -1))
153 {
154  if(options != nullptr)
155  {
156  _allocator = populate_allocator(options->allocator);
157  _caps = populate_capabilities(options->capabilities, options->max_compute_units);
158  }
159 }
Automatic discovery of capabilities.
Definition: AclTypes.h:79
int32_t max_compute_units
Max compute units that can be used by a queue created from the context.
Definition: AclTypes.h:140
AclTargetCapabilities capabilities
Target capabilities.
Definition: AclTypes.h:137
IContext(Target target)
Definition: IContext.h:53
AclAllocator * allocator
Allocator to be used by all the memory internally.
Definition: AclTypes.h:142

Member Function Documentation

◆ allocator()

AllocatorWrapper & allocator ( )

Backing memory allocator accessor.

Allocator that allocates CPU memory

Definition at line 166 of file CpuContext.cpp.

167 {
168  return _allocator;
169 }

◆ capabilities()

const CpuCapabilities & capabilities ( ) const

Cpu Capabilities accessor.

The ISA capabilities to be used by the CPU

Definition at line 161 of file CpuContext.cpp.

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

162 {
163  return _caps;
164 }

◆ create_activation()

std::tuple< IOperator *, StatusCode > create_activation ( const AclTensorDescriptor src,
const AclTensorDescriptor dst,
const AclActivationDescriptor act,
bool  is_validate 

Implements IContext.

Definition at line 49 of file CpuActivation.cpp.

References ARM_COMPUTE_LOG_ERROR_ACL, arm_compute::detail::convert_to_activation_info(), arm_compute::detail::convert_to_legacy_tensor_info(), arm_compute::test::validation::info, arm_compute::OutOfMemory, TensorInfo::set_is_resizable(), arm_compute::test::validation::src_info, arm_compute::Success, arm_compute::UnsupportedConfig, and CpuActivation::validate().

50 {
52  TensorInfo dst_info = detail::convert_to_legacy_tensor_info(dst);
55  if(is_validate && !bool(CpuActivation::validate(&src_info.set_is_resizable(false), &dst_info.set_is_resizable(false), info)))
56  {
57  return std::make_tuple(nullptr, StatusCode::UnsupportedConfig);
58  }
60  auto act_op = std::make_unique<cpu::CpuActivation>();
61  act_op->configure(&src_info, &dst_info, info);
63  auto op = new arm_compute::IOperator(static_cast<IContext *>(this));
64  if(op == nullptr)
65  {
66  ARM_COMPUTE_LOG_ERROR_ACL("Couldn't allocate internal resources");
67  return std::make_tuple(nullptr, StatusCode::OutOfMemory);
68  }
69  op->set_internal_operator(std::move(act_op));
71  return std::make_tuple(op, StatusCode::Success);
72 }
TensorInfo convert_to_legacy_tensor_info(const AclTensorDescriptor &desc)
Convert a descriptor to a legacy format one.
Base class for all async functions.
Definition: IOperator.h:37
Log an error message to the logger.
Definition: Log.h:77
TensorInfo src_info(src_shape, 1, data_type)
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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.
ActivationLayerInfo convert_to_activation_info(const AclActivationDescriptor &desc)
Convert an AclActivation descriptor to an internal one.

◆ create_queue()

IQueue * create_queue ( const AclQueueOptions options)

Create a queue object.

[in]optionsQueue options to be used
A pointer to the created queue object

Implements IContext.

Definition at line 181 of file CpuContext.cpp.

182 {
183  return new CpuQueue(this, options);
184 }

◆ create_tensor()

ITensorV2 * create_tensor ( const AclTensorDescriptor desc,
bool  allocate 

Create a tensor object.

[in]descDescriptor to use
[in]allocateFlag to allocate tensor
A pointer to the created tensor object

Implements IContext.

Definition at line 171 of file CpuContext.cpp.

References CpuTensor::allocate().

172 {
173  CpuTensor *tensor = new CpuTensor(this, desc);
174  if(tensor != nullptr && allocate)
175  {
176  tensor->allocate();
177  }
178  return tensor;
179 }

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