From a7e3913210221901b726ac6363f0698104967aac Mon Sep 17 00:00:00 2001 From: alex-yuyue Date: Mon, 14 Dec 2020 19:08:47 -0500 Subject: [PATCH] Print the row_id for map when error happens Signed-off-by: alex-yuyue --- .../dataset/engine/datasetops/map_op/cpu_map_job.cc | 10 ++++++++-- .../dataset/engine/datasetops/map_op/gpu_map_job.cc | 2 +- .../dataset/engine/datasetops/map_op/map_op.cc | 1 + mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/cpu_map_job.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/cpu_map_job.cc index adebacc393..1847538e48 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/cpu_map_job.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/cpu_map_job.cc @@ -39,7 +39,14 @@ Status CpuMapJob::Run(std::vector in, std::vector *out) { TensorRow result_row; for (size_t i = 0; i < ops_.size(); i++) { // Call compute function for cpu - RETURN_IF_NOT_OK(ops_[i]->Compute(input_row, &result_row)); + Status rc = ops_[i]->Compute(input_row, &result_row); + if (rc.IsError()) { + if (input_row.getId() >= 0) { + MS_LOG(ERROR) << "The TensorRow with id=" + std::to_string(input_row.getId()) + " failed on " + + std::to_string(i) + " TensorOp in Map: " + ops_[i]->Name(); + } + return rc; + } // Assign result_row to to_process for the next TensorOp processing, except for the last TensorOp in the list. if (i + 1 < ops_.size()) { @@ -48,7 +55,6 @@ Status CpuMapJob::Run(std::vector in, std::vector *out) { } out->push_back(std::move(result_row)); } - return Status::OK(); } diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/gpu_map_job.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/gpu_map_job.cc index 64502d6da2..801f0ac231 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/gpu_map_job.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/gpu_map_job.cc @@ -27,7 +27,7 @@ GpuMapJob::GpuMapJob(std::vector> operations) : MapJob // Destructor GpuMapJob::~GpuMapJob() = default; -// A function to execute a cpu map job +// A function to execute a gpu map job Status GpuMapJob::Run(std::vector in, std::vector *out) { // Do nothing for now return Status::OK(); diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/map_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/map_op.cc index 13c9fa2e2c..7fa026cd14 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/map_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/map_op/map_op.cc @@ -287,6 +287,7 @@ Status MapOp::WorkerCompute(DataBuffer *in_buffer, TensorQTable *new_tensor_tabl // From the current row, select the Tensor that need to be passed to TensorOp (void)std::transform(to_process_indices_.begin(), to_process_indices_.end(), std::back_inserter(to_process), [&cur_row](const auto &it) { return std::move(cur_row[it]); }); + to_process.setId(cur_row.getId()); job_input_table.push_back(std::move(to_process)); original_table.push_back(std::move(cur_row)); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h b/mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h index f192e5d77d..9bbf75cb44 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h @@ -134,7 +134,7 @@ constexpr char kCFuncOp[] = "CFuncOp"; constexpr char kPyFuncOp[] = "PyFuncOp"; constexpr char kNoOp[] = "NoOp"; -// A class that does a computation on a Tensor +// A class that does a computation on a Tensor class TensorOp { public: TensorOp() = default;