Browse Source

!2575 dataset: repair bug in GetTensor that access NullPtr

Merge pull request !2575 from ms_yan/r0.5_GetTensor
tags/v0.5.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
dd75ebfae3
2 changed files with 4 additions and 2 deletions
  1. +4
    -1
      mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.cc
  2. +0
    -1
      tests/ut/cpp/dataset/zip_op_test.cc

+ 4
- 1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.cc View File

@@ -91,11 +91,14 @@ void Sampler::Print(std::ostream &out, bool show_all) const {
Status Sampler::GetAllIdsThenReset(py::array *data) { Status Sampler::GetAllIdsThenReset(py::array *data) {
std::unique_ptr<DataBuffer> db; std::unique_ptr<DataBuffer> db;
std::shared_ptr<Tensor> sample_ids; std::shared_ptr<Tensor> sample_ids;
TensorRow sample_row;


// A call to derived class to get sample ids wrapped inside a buffer // A call to derived class to get sample ids wrapped inside a buffer
RETURN_IF_NOT_OK(GetNextSample(&db)); RETURN_IF_NOT_OK(GetNextSample(&db));
// Get the only tensor inside the buffer that contains the actual SampleIds for the entire epoch // Get the only tensor inside the buffer that contains the actual SampleIds for the entire epoch
RETURN_IF_NOT_OK(db->GetTensor(&sample_ids, 0, 0));
RETURN_IF_NOT_OK(db->GetRow(0, &sample_row));
sample_ids = sample_row[0];

// check this buffer is not a ctrl buffer // check this buffer is not a ctrl buffer
CHECK_FAIL_RETURN_UNEXPECTED(db->buffer_flags() == DataBuffer::kDeBFlagNone, "ERROR ctrl buffer received"); CHECK_FAIL_RETURN_UNEXPECTED(db->buffer_flags() == DataBuffer::kDeBFlagNone, "ERROR ctrl buffer received");
{ {


+ 0
- 1
tests/ut/cpp/dataset/zip_op_test.cc View File

@@ -125,7 +125,6 @@ TEST_F(MindDataTestZipOp, MindDataTestZipOpDefault) {
EXPECT_TRUE(rc.IsOk()); EXPECT_TRUE(rc.IsOk());
row_count++; row_count++;
} }
MS_LOG(WARNING) <<"row count is: " << row_count;
ASSERT_EQ(row_count, 3); // Should be 3 rows fetched ASSERT_EQ(row_count, 3); // Should be 3 rows fetched
} }




Loading…
Cancel
Save