From e3357e41629eee81834f6550d1f1ec3fce55bfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=85?= Date: Tue, 6 Mar 2018 19:21:15 +0800 Subject: [PATCH] Do nothing when resize image --- .../runtime/hexagon/hexagon_control_wrapper.cc | 1 - mace/core/tensor.h | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mace/core/runtime/hexagon/hexagon_control_wrapper.cc b/mace/core/runtime/hexagon/hexagon_control_wrapper.cc index aa55fd0c..8735f529 100644 --- a/mace/core/runtime/hexagon/hexagon_control_wrapper.cc +++ b/mace/core/runtime/hexagon/hexagon_control_wrapper.cc @@ -62,7 +62,6 @@ bool HexagonControlWrapper::SetupGraph(const NetDef &net_def) { // const node std::thread const_thread([&]() { - std::cout << "thread function\n"; std::vector const_node_list; for (const ConstTensor &const_tensor: net_def.tensors()) { std::vector tensor_shape(const_tensor.dims().begin(), diff --git a/mace/core/tensor.h b/mace/core/tensor.h index f1acb799..692364e3 100644 --- a/mace/core/tensor.h +++ b/mace/core/tensor.h @@ -169,6 +169,7 @@ class Tensor { inline void Resize(const std::vector &shape) { shape_ = shape; + image_shape_.clear(); if (buffer_ != nullptr) { MACE_CHECK(!has_opencl_image(), "Cannot resize image, use ResizeImage."); buffer_->Resize(raw_size()); @@ -181,24 +182,25 @@ class Tensor { inline void ResizeImage(const std::vector &shape, const std::vector &image_shape) { shape_ = shape; + image_shape_ = image_shape; if (buffer_ == nullptr) { buffer_ = new Image(image_shape, dtype_); is_buffer_owner_ = true; } else { MACE_CHECK(has_opencl_image(), "Cannot ResizeImage buffer, use Resize."); Image *image = dynamic_cast(buffer_); - MACE_CHECK(shape[0] <= image->image_shape()[0] - && shape[1] <= image->image_shape()[1], + MACE_CHECK(image_shape[0] <= image->image_shape()[0] + && image_shape[1] <= image->image_shape()[1], "tensor (source op ", name_, - "): current image shape: ", + "): current physical image shape: ", image->image_shape()[0], ", ", image->image_shape()[1], - " < resize tensor shape: ", - shape[0], + " < logical image shape: ", + image_shape[0], ", ", - shape[1]); + image_shape[1]); } } @@ -212,8 +214,7 @@ class Tensor { delete buffer_; buffer_ = nullptr; } - ResizeImage(other->shape(), - dynamic_cast(other->UnderlyingBuffer())->image_shape()); + ResizeImage(other->shape(), other->image_shape_); } else { if (is_buffer_owner_ && buffer_ != nullptr && has_opencl_image()) { delete buffer_; @@ -307,6 +308,7 @@ class Tensor { Allocator *allocator_; DataType dtype_; std::vector shape_; + std::vector image_shape_; BufferBase *buffer_; BufferSlice buffer_slice_; bool is_buffer_owner_; -- GitLab