From 4113d440ac755f34385e38f96bd38aac61e56f38 Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Mon, 19 Aug 2019 13:54:45 +0800 Subject: [PATCH] fix dim equality test && fix fetch var sync bug (#1805) --- mobile/src/framework/ddim.cpp | 4 ++++ mobile/src/framework/tensor.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mobile/src/framework/ddim.cpp b/mobile/src/framework/ddim.cpp index 3a4a3abb7c..6da08bf88e 100644 --- a/mobile/src/framework/ddim.cpp +++ b/mobile/src/framework/ddim.cpp @@ -133,6 +133,10 @@ bool DDim::operator==(DDim d) const { std::vector v1 = vectorize(*this); std::vector v2 = vectorize(d); + if (v1.size() != v2.size()) { + return false; + } + for (unsigned int i = 0; i < v1.size(); i++) { if (v1[i] != v2[i]) { return false; diff --git a/mobile/src/framework/tensor.h b/mobile/src/framework/tensor.h index 93f11d8402..7cab1408da 100644 --- a/mobile/src/framework/tensor.h +++ b/mobile/src/framework/tensor.h @@ -89,7 +89,7 @@ class Tensor : public TensorBase { /*! The internal of two tensors share the same memory block. */ inline Tensor &ShareDataWith(const Tensor &src) { src.check_memory_size(); - if (holder_.get() != src.holder_.get()) { + if (holder_.get() != src.holder_.get() || dims_ != src.dims()) { *this = src; } return *this; -- GitLab