diff --git a/mindspore/ccsrc/minddata/dataset/engine/opt/pre/removal_pass.cc b/mindspore/ccsrc/minddata/dataset/engine/opt/pre/removal_pass.cc index 3e2150e22f..5fec3f196d 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/opt/pre/removal_pass.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/opt/pre/removal_pass.cc @@ -66,7 +66,7 @@ Status RemovalPass::RunOnTree(ExecutionTree *tree, bool *modified) { // Then, execute the removal of any nodes that were set up for removal for (auto node : removal_nodes->nodes_to_remove()) { - node->Remove(); + RETURN_IF_NOT_OK(node->Remove()); } MS_LOG(INFO) << "Pre pass: removal pass complete."; return Status::OK(); diff --git a/mindspore/ccsrc/minddata/dataset/util/data_helper.cc b/mindspore/ccsrc/minddata/dataset/util/data_helper.cc index 49c70f884b..49479d4f10 100644 --- a/mindspore/ccsrc/minddata/dataset/util/data_helper.cc +++ b/mindspore/ccsrc/minddata/dataset/util/data_helper.cc @@ -23,8 +23,6 @@ #include #include -#include "minddata/dataset/core/tensor.h" -#include "minddata/dataset/core/tensor_shape.h" #include "minddata/dataset/util/log_adapter.h" #include "minddata/dataset/util/path.h" #include "minddata/dataset/util/status.h" @@ -122,12 +120,8 @@ Status DataHelper::RemoveKey(const std::string &in_file, const std::string &key, return Status::OK(); } -size_t DataHelper::DumpTensor(const std::shared_ptr &input, void *addr, const size_t &buffer_size) { - // get tensor size - size_t tensor_size = input->SizeInBytes(); - // iterate over entire tensor - const unsigned char *tensor_addr = input->GetBuffer(); - // tensor iterator print +size_t DataHelper::DumpData(const unsigned char *tensor_addr, const size_t &tensor_size, void *addr, + const size_t &buffer_size) { // write to address, input order is: destination, source errno_t ret = memcpy_s(addr, buffer_size, tensor_addr, tensor_size); if (ret != 0) { diff --git a/mindspore/ccsrc/minddata/dataset/util/data_helper.h b/mindspore/ccsrc/minddata/dataset/util/data_helper.h index bf2e7f10a4..dd3a5570b6 100644 --- a/mindspore/ccsrc/minddata/dataset/util/data_helper.h +++ b/mindspore/ccsrc/minddata/dataset/util/data_helper.h @@ -25,11 +25,7 @@ #include #include #include - -#include "minddata/dataset/core/constants.h" -#include "minddata/dataset/core/data_type.h" -#include "minddata/dataset/core/tensor.h" -#include "minddata/dataset/core/tensor_shape.h" +#include "./securec.h" #include "minddata/dataset/util/log_adapter.h" #include "minddata/dataset/util/path.h" #include "minddata/dataset/util/status.h" @@ -181,11 +177,12 @@ class DataHelper { /// \brief Helper function to copy content of a tensor to buffer /// \note This function iterates over the tensor in bytes, since - /// \param[in] input The tensor to copy value from + /// \param[in] tensor_addr The memory held by a tensor, e.g. tensor->GetBuffer() + /// \param[in] tensor_size The amount of data in bytes in tensor_addr, e.g. tensor->SizeInBytes() /// \param[out] addr The address to copy tensor data to /// \param[in] buffer_size The buffer size of addr /// \return The size of the tensor (bytes copied - size_t DumpTensor(const std::shared_ptr &input, void *addr, const size_t &buffer_size); + size_t DumpData(const unsigned char *tensor_addr, const size_t &tensor_size, void *addr, const size_t &buffer_size); /// \brief Helper function to delete key in json file /// note This function will return okay even if key not found diff --git a/tests/ut/cpp/dataset/data_helper_test.cc b/tests/ut/cpp/dataset/data_helper_test.cc index 74db1ab29d..3262279b66 100644 --- a/tests/ut/cpp/dataset/data_helper_test.cc +++ b/tests/ut/cpp/dataset/data_helper_test.cc @@ -153,7 +153,7 @@ TEST_F(MindDataTestDataHelper, MindDataTestTensorWriteFloat) { // create buffer using system mempool DataHelper dh; void *data = malloc(t->SizeInBytes()); - auto bytes_copied = dh.DumpTensor(std::move(t), data, t->SizeInBytes()); + auto bytes_copied = dh.DumpData(t->GetBuffer(), t->SizeInBytes(), data, t->SizeInBytes()); if (bytes_copied != t->SizeInBytes()) { EXPECT_TRUE(false); } @@ -177,7 +177,7 @@ TEST_F(MindDataTestDataHelper, MindDataTestTensorWriteUInt) { // create buffer using system mempool DataHelper dh; void *data = malloc(t->SizeInBytes()); - auto bytes_copied = dh.DumpTensor(t, data, t->SizeInBytes()); + auto bytes_copied = dh.DumpData(t->GetBuffer(), t->SizeInBytes(), data, t->SizeInBytes()); if (bytes_copied != t->SizeInBytes()) { EXPECT_TRUE(false); }