diff --git a/mace/core/tensor.h b/mace/core/tensor.h index 47fa3d11387c258e8cc96d55b7a9cca68a94f9e0..f1acb799ca793a4a293a096b14cc46d920d4e289 100644 --- a/mace/core/tensor.h +++ b/mace/core/tensor.h @@ -68,17 +68,20 @@ class Tensor { : allocator_(alloc), dtype_(type), buffer_(nullptr), - is_buffer_owner_(true) {}; + is_buffer_owner_(true), + name_("") {}; Tensor(BufferBase *buffer, DataType dtype) : dtype_(dtype), buffer_(buffer), - is_buffer_owner_(false) {} + is_buffer_owner_(false), + name_("") {} Tensor(const BufferSlice &buffer_slice, DataType dtype) : dtype_(dtype), buffer_slice_(buffer_slice), - is_buffer_owner_(false) { + is_buffer_owner_(false), + name_("") { buffer_ = &buffer_slice_; } @@ -184,8 +187,18 @@ class Tensor { } else { MACE_CHECK(has_opencl_image(), "Cannot ResizeImage buffer, use Resize."); Image *image = dynamic_cast(buffer_); - MACE_CHECK(image_shape[0] <= image->image_shape()[0] - && image_shape[1] <= image->image_shape()[1]); + MACE_CHECK(shape[0] <= image->image_shape()[0] + && shape[1] <= image->image_shape()[1], + "tensor (source op ", + name_, + "): current image shape: ", + image->image_shape()[0], + ", ", + image->image_shape()[1], + " < resize tensor shape: ", + shape[0], + ", ", + shape[1]); } } @@ -238,6 +251,10 @@ class Tensor { return buffer_; } + inline void SetSourceOpName(const std::string name) { + name_ = name; + } + inline void DebugPrint() const { using namespace numerical_chars; std::stringstream os; @@ -293,6 +310,7 @@ class Tensor { BufferBase *buffer_; BufferSlice buffer_slice_; bool is_buffer_owner_; + std::string name_; DISABLE_COPY_AND_ASSIGN(Tensor); }; diff --git a/mace/core/workspace.cc b/mace/core/workspace.cc index a7adb9395a4119cd9858bfdb7cc293149251e97a..59c509e71f672361d8d3643f3c41424ee3480131 100644 --- a/mace/core/workspace.cc +++ b/mace/core/workspace.cc @@ -143,6 +143,12 @@ void Workspace::CreateImageOutputTensor(const NetDef &net_def) { if (op.has_mem_id()) { std::unique_ptr tensor (new Tensor(preallocated_allocator_.GetBuffer(op.mem_id()), dtype)); + tensor->SetSourceOpName(op.name()); + VLOG(3) << "Tensor: " << op.name() << "(" << op.type() << ")" << "; Mem: " + << op.mem_id() << "; Image shape: " + << dynamic_cast(tensor->UnderlyingBuffer())->image_shape()[0] + << ", " + << dynamic_cast(tensor->UnderlyingBuffer())->image_shape()[1]; tensor_map_[op.output(0)] = std::move(tensor); } }