MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / allocate_region

Function allocate_region

src/runtime/CL/CLTensorAllocator.cpp:46–63  ·  view source on GitHub ↗

Helper function used to allocate the backing memory of a tensor * * @param[in] size Size of the allocation * @param[in] alignment Alignment of the allocation * * @return A wrapped memory region */

Source from the content-addressed store, hash-verified

44 * @return A wrapped memory region
45 */
46std::unique_ptr<ICLMemoryRegion> allocate_region(size_t size, cl_uint alignment)
47{
48 // Try fine-grain SVM
49 std::unique_ptr<ICLMemoryRegion> region =
50 std::make_unique<CLFineSVMMemoryRegion>(CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, size, alignment);
51
52 // Try coarse-grain SVM in case of failure
53 if (region != nullptr && region->ptr() == nullptr)
54 {
55 region = std::make_unique<CLCoarseSVMMemoryRegion>(CL_MEM_READ_WRITE, size, alignment);
56 }
57 // Try legacy buffer memory in case of failure
58 if (region != nullptr && region->ptr() == nullptr)
59 {
60 region = std::make_unique<CLBufferMemoryRegion>(CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size);
61 }
62 return region;
63}
64/** Clears quantization arrays
65 *
66 * @param[in, out] scale Quantization scale array

Callers 1

allocateMethod · 0.85

Calls 1

ptrMethod · 0.45

Tested by

no test coverage detected