diff --git a/mobile/src/framework/ddim.cpp b/mobile/src/framework/ddim.cpp index 3a4a3abb7cd4c632251e6f0190e32c99dd232c01..6da08bf88ea9ed04b21213b921f66002b7a78b66 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 93f11d84024033805baef1d1e9073585f1c75729..7cab1408daae9e9c3f34e64d37a3dace054665ce 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;