From 028f3dc4e5fcb558041ff168e233a89b41aeaed9 Mon Sep 17 00:00:00 2001 From: liaogang Date: Wed, 19 Jul 2017 13:13:19 +0800 Subject: [PATCH] Add memcpy --- paddle/memory/memory.cc | 14 ++++++++++++++ paddle/memory/memory.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/paddle/memory/memory.cc b/paddle/memory/memory.cc index 430ce98bfc1..5be9bef3ac3 100644 --- a/paddle/memory/memory.cc +++ b/paddle/memory/memory.cc @@ -47,6 +47,20 @@ size_t Used(platform::CPUPlace place) { return GetCPUBuddyAllocator()->Used(); } +template <> +void Copy(platform::CPUPlace, void* dst, + platform::CPUPlace, void* src, + size_t size) { + memcpy(dst, src, size); +} + +template <> +void Copy(platform::CPUPlace, void* dst, + platform::CPUPlace, void* src, + size_t size) { + memcpy(dst, src, size); +} + #ifndef PADDLE_ONLY_CPU detail::BuddyAllocator* GetGPUBuddyAllocator(int gpu_id) { diff --git a/paddle/memory/memory.h b/paddle/memory/memory.h index 2d6f4fd2a08..96c00cb106b 100644 --- a/paddle/memory/memory.h +++ b/paddle/memory/memory.h @@ -28,5 +28,8 @@ void Free(Place, void*); template size_t Used(Place); +template +void Copy(Place1, void* dst, Place2, void* src, size_t size); + } // namespace memory } // namespace paddle -- GitLab