Browse Source

!6479 fix bucket_batch_by_length show pyfunc timeout

Merge pull request !6479 from yanghaitao/yht_bucket_batch_ci
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
1cfad93704
3 changed files with 6 additions and 8 deletions
  1. +4
    -6
      mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc
  2. +1
    -1
      mindspore/dataset/engine/datasets.py
  3. +1
    -1
      tests/ut/python/dataset/test_paddeddataset.py

+ 4
- 6
mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc View File

@@ -50,14 +50,8 @@ Status PyFuncOp::Compute(const TensorRow &input, TensorRow *output) {
} else {
ret_py_obj = this->py_func_ptr_();
}
// Object is none if pyfunc timeout
if (ret_py_obj.is_none()) {
MS_LOG(INFO) << "Pyfunc execute time out";
goto TimeoutError;
}
if (output_type_ != DataType::DE_UNKNOWN) {
RETURN_IF_NOT_OK(CastOutput(ret_py_obj, output));

} else {
if (py::isinstance<py::tuple>(ret_py_obj)) {
// In case of a n-m mapping, the return value will be a tuple of numpy arrays
@@ -65,6 +59,10 @@ Status PyFuncOp::Compute(const TensorRow &input, TensorRow *output) {
// Iterate over two containers simultaneously for memory copy
for (size_t i = 0; i < ret_py_tuple.size(); i++) {
py::object ret_py_ele = ret_py_tuple[i];
// Object is none if pyfunc timeout
if (ret_py_ele.is_none()) {
goto TimeoutError;
}
if (!py::isinstance<py::array>(ret_py_ele)) {
goto ShapeMisMatch;
}


+ 1
- 1
mindspore/dataset/engine/datasets.py View File

@@ -1999,7 +1999,7 @@ class _PythonCallable:
return result.get(60)
except multiprocessing.TimeoutError:
# Ensure c++ pyfunc threads exit normally if python sub-process is killed unnormally.
return None
return (None,)
except KeyboardInterrupt:
self.pool.terminate()
self.pool.join()


+ 1
- 1
tests/ut/python/dataset/test_paddeddataset.py View File

@@ -504,7 +504,7 @@ def test_celeba_padded():
count = 0
for _ in data.create_dict_iterator(num_epochs=1, output_numpy=True):
count = count + 1
assert count == 2
assert count == 4


if __name__ == '__main__':


Loading…
Cancel
Save