未验证 提交 47f3cae2 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #11038 from sneaxiy/zjl-dev

Fix bug in "paddle/fluid/framework/tensor_impl.h" and inefficient code in "paddle/fluid/framework/reader.cc"
...@@ -25,8 +25,10 @@ void FileReader::ReadNext(std::vector<LoDTensor> *out) { ...@@ -25,8 +25,10 @@ void FileReader::ReadNext(std::vector<LoDTensor> *out) {
if (out->empty()) { if (out->empty()) {
return; return;
} }
PADDLE_ENFORCE_EQ(out->size(), dims_.size());
for (size_t i = 0; i < dims_.size(); ++i) { for (size_t i = 0; i < dims_.size(); ++i) {
auto &actual = out->at(i).dims(); auto &actual = (*out)[i].dims();
auto &expect = dims_[i]; auto &expect = dims_[i];
PADDLE_ENFORCE_EQ(actual.size(), expect.size()); PADDLE_ENFORCE_EQ(actual.size(), expect.size());
......
...@@ -39,7 +39,7 @@ template <typename T> ...@@ -39,7 +39,7 @@ template <typename T>
inline const T* Tensor::data() const { inline const T* Tensor::data() const {
check_memory_size(); check_memory_size();
PADDLE_ENFORCE(std::is_same<T, void>::value || PADDLE_ENFORCE(std::is_same<T, void>::value ||
holder_->type().hash_code() == typeid(T).hash_code(), holder_->type() == std::type_index(typeid(T)),
"Tensor holds the wrong type, it holds %s", "Tensor holds the wrong type, it holds %s",
this->holder_->type().name()); this->holder_->type().name());
...@@ -53,7 +53,7 @@ template <typename T> ...@@ -53,7 +53,7 @@ template <typename T>
inline T* Tensor::data() { inline T* Tensor::data() {
check_memory_size(); check_memory_size();
PADDLE_ENFORCE(std::is_same<T, void>::value || PADDLE_ENFORCE(std::is_same<T, void>::value ||
holder_->type().hash_code() == typeid(T).hash_code(), holder_->type() == std::type_index(typeid(T)),
"Tensor holds the wrong type, it holds %s", "Tensor holds the wrong type, it holds %s",
this->holder_->type().name()); this->holder_->type().name());
return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(holder_->ptr()) + return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(holder_->ptr()) +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册