From db5f1aa59c72cc09ee60fb4c6fd3e200c71e53c9 Mon Sep 17 00:00:00 2001 From: Jiaying Zhao Date: Mon, 22 Jul 2019 14:07:36 +0800 Subject: [PATCH] add implementation of virtual function for GPU and fpga (#1762) --- src/framework/cl/cl_tensor.h | 7 +++++++ src/framework/zynqmp/ztensor.hpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/framework/cl/cl_tensor.h b/src/framework/cl/cl_tensor.h index 01fdc7970e..5bb4055eff 100644 --- a/src/framework/cl/cl_tensor.h +++ b/src/framework/cl/cl_tensor.h @@ -168,6 +168,13 @@ class CLTensor : public TensorBase { size_ = size; } + virtual void realloc(size_t size) { + capatity_ = size; + ptr_.reset( + clCreateBuffer(context_, CL_MEM_READ_WRITE, capatity_, NULL, NULL)); + size_ = size; + } + std::unique_ptr<_cl_mem, CLMemDeleter> ptr_; size_t size_; diff --git a/src/framework/zynqmp/ztensor.hpp b/src/framework/zynqmp/ztensor.hpp index cd49a0acb3..d68e43b6dc 100644 --- a/src/framework/zynqmp/ztensor.hpp +++ b/src/framework/zynqmp/ztensor.hpp @@ -247,6 +247,12 @@ class Tensor : public TensorBase { size_ = size; } + virtual void realloc(size_t size) { + capatity_ = size; + // TODO(chonwhite) implement; + size_ = size; + } + void resize(DDim ddim, const kTypeId_t type) { std::vector v = framework::vectorize2int(ddim); -- GitLab