提交 aec0d8c9 编写于 作者: W wuchenghui

fix memory reuse

上级 e5ada494
...@@ -15,6 +15,7 @@ load( ...@@ -15,6 +15,7 @@ load(
"if_production_mode", "if_production_mode",
"if_not_production_mode", "if_not_production_mode",
"if_openmp_enabled", "if_openmp_enabled",
"if_neon_enabled",
) )
cc_library( cc_library(
...@@ -47,7 +48,11 @@ cc_library( ...@@ -47,7 +48,11 @@ cc_library(
"-DMACE_ENABLE_OPENMP", "-DMACE_ENABLE_OPENMP",
]) + if_android([ ]) + if_android([
"-DMACE_ENABLE_OPENCL", "-DMACE_ENABLE_OPENCL",
]) + if_hexagon_enabled(["-DMACE_ENABLE_HEXAGON"]), ]) + if_hexagon_enabled([
"-DMACE_ENABLE_HEXAGON",
]) + if_neon_enabled([
"-DMACE_ENABLE_NEON",
]),
linkopts = ["-ldl"] + if_android([ linkopts = ["-ldl"] + if_android([
"-pie", "-pie",
"-lm", "-lm",
......
...@@ -222,6 +222,8 @@ class Tensor { ...@@ -222,6 +222,8 @@ class Tensor {
if (buffer_ != nullptr) { if (buffer_ != nullptr) {
MACE_CHECK(!has_opencl_image(), "Cannot resize image, use ResizeImage."); MACE_CHECK(!has_opencl_image(), "Cannot resize image, use ResizeImage.");
if (raw_size() + EXTRA_BUFFER_PAD_SIZE > buffer_->size()) { if (raw_size() + EXTRA_BUFFER_PAD_SIZE > buffer_->size()) {
LOG(WARNING) << "Resize buffer from size " << buffer_->size() << " to "
<< raw_size() + EXTRA_BUFFER_PAD_SIZE;
return buffer_->Resize(raw_size() + EXTRA_BUFFER_PAD_SIZE); return buffer_->Resize(raw_size() + EXTRA_BUFFER_PAD_SIZE);
} }
return MaceStatus::MACE_SUCCESS; return MaceStatus::MACE_SUCCESS;
......
...@@ -177,7 +177,7 @@ MaceStatus Workspace::CreateOutputTensorBuffer(const NetDef &net_def, ...@@ -177,7 +177,7 @@ MaceStatus Workspace::CreateOutputTensorBuffer(const NetDef &net_def,
std::unique_ptr<BufferBase> tensor_buf( std::unique_ptr<BufferBase> tensor_buf(
new Buffer(GetDeviceAllocator(device_type))); new Buffer(GetDeviceAllocator(device_type)));
MaceStatus status = tensor_buf->Allocate( MaceStatus status = tensor_buf->Allocate(
mem_block.x() * GetEnumTypeSize(dtype)); mem_block.x() * GetEnumTypeSize(dtype) + EXTRA_BUFFER_PAD_SIZE);
if (status != MaceStatus::MACE_SUCCESS) { if (status != MaceStatus::MACE_SUCCESS) {
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册