31 #if !defined(__APPLE__) && !defined(__OpenBSD__) 33 #endif // !defined(__APPLE__) && !defined(__OpenBSD__) 42 void *default_allocate(
void *user_data,
size_t size)
45 return ::operator
new(size);
47 void default_free(
void *user_data,
void *ptr)
50 ::operator
delete(ptr);
52 void *default_aligned_allocate(
void *user_data,
size_t size,
size_t alignment)
56 #if defined(BARE_METAL) 57 size_t rem = size % alignment;
58 size_t real_size = (rem) ? (size + alignment - rem) : size;
59 ptr = memalign(alignment, real_size);
61 if(posix_memalign(&ptr, alignment, size) != 0)
71 void default_aligned_free(
void *user_data,
void *ptr)
76 static AclAllocator default_allocator = { &default_allocate,
78 &default_aligned_allocate,
79 &default_aligned_free,
83 AllocatorWrapper populate_allocator(
AclAllocator *external_allocator)
85 bool is_valid = (external_allocator !=
nullptr);
88 is_valid = is_valid && (external_allocator->
alloc !=
nullptr);
89 is_valid = is_valid && (external_allocator->
free !=
nullptr);
90 is_valid = is_valid && (external_allocator->
aligned_alloc !=
nullptr);
91 is_valid = is_valid && (external_allocator->
aligned_free !=
nullptr);
93 return is_valid ? AllocatorWrapper(*external_allocator) : AllocatorWrapper(default_allocator);
98 cpuinfo::CpuIsaInfo isa_caps;
108 isa_caps.svebf16 = isa_caps.bf16;
121 CpuCapabilities caps;
127 cpuinfo::CpuIsaInfo isa = populate_capabilities_flags(external_caps);
128 auto cpus = caps.cpu_info.cpus();
130 caps.cpu_info = cpuinfo::CpuInfo(isa, cpus);
134 #if defined(BARE_METAL) 136 caps.max_threads = 1;
138 caps.max_threads = (max_threads > 0) ? max_threads : std::thread::hardware_concurrency();
147 _allocator(default_allocator),
150 if(options !=
nullptr)
152 _allocator = populate_allocator(options->
allocator);
170 if(tensor !=
nullptr && allocate)
static CpuInfo build()
CpuInfo builder function from system related information.
Base class specifying the queue interface.
Enable bfloat16 data-type support.
Structure that encodes the CPU capabilities to be used.
Base class specifying the tensor interface.
void(* free)(void *user_data, void *ptr)
Release a block of size bytes of memory.
Automatic discovery of capabilities.
Enable SVE optimized paths.
int32_t max_compute_units
Max compute units that can be used by a queue created from the context.
#define ARM_COMPUTE_LOG_ERROR_ACL(msg)
Log an error message to the logger.
Enable paths that use the mmla integer instructions.
Enable NEON optimized paths.
Copyright (c) 2017-2021 Arm Limited.
AclTargetCapabilities capabilities
Target capabilities.
uint64_t AclTargetCapabilities
Error codes returned by the public entry-points.
void *(* alloc)(void *user_data, size_t size)
Allocate a block of size bytes of memory.
AllocatorWrapper & allocator()
Backing memory allocator accessor.
StatusCode allocate()
Allocates tensor.
void *(* aligned_alloc)(void *user_data, size_t size, size_t alignment)
Allocate a block of size bytes of memory.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
CpuContext(const AclContextOptions *options)
Default Constructor.
const CpuCapabilities & capabilities() const
Cpu Capabilities accessor.
Enable SVE2 optimized paths.
CPU tensor implementation class.
CPU queue implementation class.
void(* aligned_free)(void *user_data, void *ptr)
Allocate a block of size bytes of memory.
IQueue * create_queue(const AclQueueOptions *options) override
Create a queue object.
Default malloc allocator implementation.
Enable paths that use the mmla float instructions.
ITensorV2 * create_tensor(const AclTensorDescriptor &desc, bool allocate) override
Create a tensor object.
Enable float16 data-type support.
AclAllocator * allocator
Allocator to be used by all the memory internally.
Enable paths that use the udot/sdot instructions.