Lines Matching refs:memory

183 RuntimeMemory::RuntimeMemory(SharedMemory memory) : kMemory(std::move(memory)) {  in RuntimeMemory()  argument
188 RuntimeMemory::RuntimeMemory(SharedMemory memory, std::unique_ptr<MemoryValidatorBase> validator) in RuntimeMemory() argument
189 : kMemory(std::move(memory)), mValidator(std::move(validator)) { in RuntimeMemory()
258 const SharedMemory& memory = memoryAHWB->getMemory(); in copyIBuffers() local
259 if (!validate(memory).ok()) return ANEURALNETWORKS_OUT_OF_MEMORY; in copyIBuffers()
260 NN_RETURN_IF_ERROR(copyIBufferToMemory(src, memory)); in copyIBuffers()
261 NN_RETURN_IF_ERROR(copyMemoryToIBuffer(memory, dst, srcMetadata.dimensions)); in copyIBuffers()
479 std::unique_ptr<RuntimeMemory> memory; in allocate() local
484 std::tie(n, memory) = mAllocator->allocate(mDesc, mOperand->type); in allocate()
492 std::tie(n, memory) = MemoryRuntimeAHWB::create(size); in allocate()
495 std::tie(n, memory) = MemoryAshmem::create(size); in allocate()
500 CHECK(memory != nullptr); in allocate()
503 memory->setValidator(std::move(validator)); in allocate()
505 return {n, std::move(memory)}; in allocate()
509 auto memory = createSharedMemory(size); in create() local
510 if (!memory.has_value()) { in create()
511 LOG(ERROR) << "RuntimeMemory::create() failed: " << memory.error().message; in create()
512 return {convertErrorStatusToResultCode(memory.error().code), nullptr}; in create()
514 auto mapping = map(memory.value()); in create()
520 std::make_unique<MemoryAshmem>(std::move(memory).value(), std::move(mapping).value())}; in create()
527 MemoryAshmem::MemoryAshmem(SharedMemory memory, Mapping mapping) in MemoryAshmem() argument
528 : RuntimeMemory(std::move(memory)), kMapping(std::move(mapping)) {} in MemoryAshmem()
532 auto memory = createSharedMemoryFromFd(size, prot, fd, offset); in create() local
533 if (!memory.has_value()) { in create()
534 LOG(ERROR) << "Failed to create memory from fd: " << memory.error().message; in create()
535 return {convertErrorStatusToResultCode(memory.error().code), nullptr}; in create()
537 return {ANEURALNETWORKS_NO_ERROR, std::make_unique<MemoryFd>(std::move(memory).value())}; in create()
540 MemoryFd::MemoryFd(SharedMemory memory) : RuntimeMemory(std::move(memory)) {} in MemoryFd() argument
543 auto memory = createSharedMemoryFromAHWB(const_cast<AHardwareBuffer*>(&ahwb), in create() local
545 if (!memory.has_value()) { in create()
546 LOG(ERROR) << "Failed to create memory from AHWB: " << memory.error().message; in create()
547 return {convertErrorStatusToResultCode(memory.error().code), nullptr}; in create()
551 if (isAhwbBlob(memory.value())) { in create()
552 validator = std::make_unique<SizedMemoryValidator>(nn::getSize(memory.value())); in create()
557 auto memoryAHWB = std::make_unique<MemoryAHWB>(std::move(memory).value(), std::move(validator)); in create()
578 auto memory = createSharedMemoryFromAHWB(ahwb, /*takeOWnership=*/true); in create() local
579 if (!memory.has_value()) { in create()
580 LOG(ERROR) << "Failed to allocate BLOB mode AHWB: " << memory.error().message; in create()
581 return {convertErrorStatusToResultCode(memory.error().code), nullptr}; in create()
583 auto mapping = map(memory.value()); in create()
588 auto memoryAHWB = std::make_unique<MemoryRuntimeAHWB>(std::move(memory).value(), in create()
597 MemoryRuntimeAHWB::MemoryRuntimeAHWB(SharedMemory memory, Mapping mapping) in MemoryRuntimeAHWB() argument
598 : RuntimeMemory(std::move(memory)), kMapping(std::move(mapping)) {} in MemoryRuntimeAHWB()