Skip to content

Commit 47f3cae

Browse files
authored
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"
2 parents 60c2d03 + 46f1323 commit 47f3cae

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

paddle/fluid/framework/reader.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ void FileReader::ReadNext(std::vector<LoDTensor> *out) {
2525
if (out->empty()) {
2626
return;
2727
}
28+
29+
PADDLE_ENFORCE_EQ(out->size(), dims_.size());
2830
for (size_t i = 0; i < dims_.size(); ++i) {
29-
auto &actual = out->at(i).dims();
31+
auto &actual = (*out)[i].dims();
3032
auto &expect = dims_[i];
3133

3234
PADDLE_ENFORCE_EQ(actual.size(), expect.size());

paddle/fluid/framework/tensor_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ template <typename T>
3939
inline const T* Tensor::data() const {
4040
check_memory_size();
4141
PADDLE_ENFORCE(std::is_same<T, void>::value ||
42-
holder_->type().hash_code() == typeid(T).hash_code(),
42+
holder_->type() == std::type_index(typeid(T)),
4343
"Tensor holds the wrong type, it holds %s",
4444
this->holder_->type().name());
4545

@@ -53,7 +53,7 @@ template <typename T>
5353
inline T* Tensor::data() {
5454
check_memory_size();
5555
PADDLE_ENFORCE(std::is_same<T, void>::value ||
56-
holder_->type().hash_code() == typeid(T).hash_code(),
56+
holder_->type() == std::type_index(typeid(T)),
5757
"Tensor holds the wrong type, it holds %s",
5858
this->holder_->type().name());
5959
return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(holder_->ptr()) +

0 commit comments

Comments
 (0)