* limitations under the License.
*/
+#include <arm_compute/runtime/CL/CLScheduler.h>
+#include <arm_compute/runtime/CL/CLMemory.h>
+#include <arm_compute/runtime/CL/CLMemoryRegion.h>
#include "CLTensor.h"
#include "backend/acl_cl/Convert.h"
void CLTensor::doUnmap(cl::CommandQueue &q) { allocator()->unmap(q, buffer()); }
+void CLTensor::setBuffer(void *host_ptr)
+{
+ // create empty MemoryRegion: just context. Since flag isn't used here, no matter which flag to
+ // pass
+ auto memory = arm_compute::CLMemory(std::make_shared<arm_compute::CLBufferMemoryRegion>(
+ arm_compute::CLScheduler::get().context(), CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, 0));
+
+ // set buffer
+ auto mem = reinterpret_cast<cl::Buffer *>(memory.region()->handle());
+ *mem = cl::Buffer(arm_compute::CLScheduler::get().context(),
+ CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, info()->total_size(), host_ptr);
+ // set correct buffer size
+ memory.region()->set_size(info()->total_size());
+ // import memory
+ allocator()->import_memory(memory);
+}
+
} // namespace operand
} // namespace acl_cl
} // namespace backend
arm_compute::CLTensorAllocator *allocator();
void map(bool blocking = true);
void unmap();
+ void setBuffer(void *host_ptr);
protected:
uint8_t *doMap(cl::CommandQueue &q, bool blocking) override;