diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/sampler/sampler.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/sampler/sampler.cc index eb952b1608ea0a9db333a2d4010a0ded82a2db47..f13e8122c805672c0d029ee419fed3946cea14a5 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/sampler/sampler.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/sampler/sampler.cc @@ -101,6 +101,13 @@ Status Sampler::GetAllIdsThenReset(py::array *data) { // check this buffer is not a ctrl buffer CHECK_FAIL_RETURN_UNEXPECTED(db->buffer_flags() == DataBuffer::kDeBFlagNone, "ERROR ctrl buffer received"); + + // perform error checking! Next buffer supposed to be EOE since last one already contains all ids for current epoch + RETURN_IF_NOT_OK(GetNextSample(&db)); + CHECK_FAIL_RETURN_UNEXPECTED(db->eoe(), "ERROR Non EOE received"); + // Reset Sampler since this is the end of the epoch + RETURN_IF_NOT_OK(ResetSampler()); + { py::gil_scoped_acquire gil_acquire; if (Py_IsInitialized() == 0) { @@ -112,11 +119,6 @@ Status Sampler::GetAllIdsThenReset(py::array *data) { return Status(StatusCode::kPyFuncException, e.what()); } } - // perform error checking! Next buffer supposed to be EOE since last one already contains all ids for current epoch - RETURN_IF_NOT_OK(GetNextSample(&db)); - CHECK_FAIL_RETURN_UNEXPECTED(db->eoe(), "ERROR Non EOE received"); - // Reset Sampler since this is the end of the epoch - RETURN_IF_NOT_OK(ResetSampler()); return Status::OK(); } #endif