提交 97603f1e 编写于 作者: L Liangliang He

Merge branch 'master' into 'master'

Check: image shape >:> tensor shape

See merge request !263
......@@ -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<Image*>(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);
};
......
......@@ -143,6 +143,12 @@ void Workspace::CreateImageOutputTensor(const NetDef &net_def) {
if (op.has_mem_id()) {
std::unique_ptr<Tensor> 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<Image *>(tensor->UnderlyingBuffer())->image_shape()[0]
<< ", "
<< dynamic_cast<Image *>(tensor->UnderlyingBuffer())->image_shape()[1];
tensor_map_[op.output(0)] = std::move(tensor);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册