From c730df23e87df4f3aa181547495933c918ba2758 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 16 Mar 2021 18:32:42 -0400 Subject: [PATCH] Added json fix 2 --- .../ccsrc/minddata/dataset/api/datasets.cc | 26 +++++++++---------- .../ccsrc/minddata/dataset/include/datasets.h | 24 ++++++++--------- .../dataset/c_api_dataset_minddata_test.cc | 14 +++++----- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/api/datasets.cc b/mindspore/ccsrc/minddata/dataset/api/datasets.cc index 7281119910..f79af55815 100644 --- a/mindspore/ccsrc/minddata/dataset/api/datasets.cc +++ b/mindspore/ccsrc/minddata/dataset/api/datasets.cc @@ -19,7 +19,7 @@ #include #include #include -#include // we need this before the include to avoid ambiguity in nullptr conversion +#include #include "minddata/dataset/core/tensor.h" #include "minddata/dataset/engine/runtime_context.h" @@ -988,54 +988,54 @@ ManifestDataset::ManifestDataset(const std::vector &dataset_file, const st MindDataDataset::MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, - const std::shared_ptr &sampler, nlohmann::json padded_sample, + const std::shared_ptr &sampler, nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler ? sampler->Parse() : nullptr; auto ds = std::make_shared(CharToString(dataset_file), VectorCharToString(columns_list), sampler_obj, - padded_sample, num_padded); + *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } MindDataDataset::MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, Sampler *sampler, - nlohmann::json padded_sample, int64_t num_padded) { + nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler ? sampler->Parse() : nullptr; auto ds = std::make_shared(CharToString(dataset_file), VectorCharToString(columns_list), sampler_obj, - padded_sample, num_padded); + *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } MindDataDataset::MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, - const std::reference_wrapper sampler, nlohmann::json padded_sample, + const std::reference_wrapper sampler, nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler.get().Parse(); auto ds = std::make_shared(CharToString(dataset_file), VectorCharToString(columns_list), sampler_obj, - padded_sample, num_padded); + *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } MindDataDataset::MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, - const std::shared_ptr &sampler, nlohmann::json padded_sample, + const std::shared_ptr &sampler, nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler ? sampler->Parse() : nullptr; auto ds = std::make_shared(VectorCharToString(dataset_files), VectorCharToString(columns_list), - sampler_obj, padded_sample, num_padded); + sampler_obj, *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } MindDataDataset::MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, Sampler *sampler, - nlohmann::json padded_sample, int64_t num_padded) { + nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler ? sampler->Parse() : nullptr; auto ds = std::make_shared(VectorCharToString(dataset_files), VectorCharToString(columns_list), - sampler_obj, padded_sample, num_padded); + sampler_obj, *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } MindDataDataset::MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, - const std::reference_wrapper sampler, nlohmann::json padded_sample, + const std::reference_wrapper sampler, nlohmann::json *padded_sample, int64_t num_padded) { auto sampler_obj = sampler.get().Parse(); auto ds = std::make_shared(VectorCharToString(dataset_files), VectorCharToString(columns_list), - sampler_obj, padded_sample, num_padded); + sampler_obj, *padded_sample, num_padded); ir_node_ = std::static_pointer_cast(ds); } #endif diff --git a/mindspore/ccsrc/minddata/dataset/include/datasets.h b/mindspore/ccsrc/minddata/dataset/include/datasets.h index 4803991ee5..a4d108fea7 100644 --- a/mindspore/ccsrc/minddata/dataset/include/datasets.h +++ b/mindspore/ccsrc/minddata/dataset/include/datasets.h @@ -1242,21 +1242,21 @@ inline std::shared_ptr Manifest(const std::string &dataset_file class MindDataDataset : public Dataset { public: explicit MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, - const std::shared_ptr &sampler, nlohmann::json padded_sample, int64_t num_padded); + const std::shared_ptr &sampler, nlohmann::json *padded_sample, int64_t num_padded); explicit MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, - Sampler *sampler, nlohmann::json padded_sample, int64_t num_padded); + Sampler *sampler, nlohmann::json *padded_sample, int64_t num_padded); explicit MindDataDataset(const std::vector &dataset_file, const std::vector> &columns_list, - const std::reference_wrapper sampler, nlohmann::json padded_sample, + const std::reference_wrapper sampler, nlohmann::json *padded_sample, int64_t num_padded); explicit MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, const std::shared_ptr &sampler, - nlohmann::json padded_sample, int64_t num_padded); + nlohmann::json *padded_sample, int64_t num_padded); explicit MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, Sampler *sampler, - nlohmann::json padded_sample, int64_t num_padded); + nlohmann::json *padded_sample, int64_t num_padded); explicit MindDataDataset(const std::vector> &dataset_files, const std::vector> &columns_list, - const std::reference_wrapper sampler, nlohmann::json padded_sample, + const std::reference_wrapper sampler, nlohmann::json *padded_sample, int64_t num_padded); ~MindDataDataset() = default; }; @@ -1274,7 +1274,7 @@ class MindDataDataset : public Dataset { /// \return Shared pointer to the current MindDataDataset inline std::shared_ptr MindData( const std::string &dataset_file, const std::vector &columns_list = {}, - const std::shared_ptr &sampler = std::make_shared(), nlohmann::json padded_sample = nullptr, + const std::shared_ptr &sampler = std::make_shared(), nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); @@ -1291,7 +1291,7 @@ inline std::shared_ptr MindData( /// \return Shared pointer to the current MindDataDataset inline std::shared_ptr MindData(const std::string &dataset_file, const std::vector &columns_list, Sampler *sampler, - nlohmann::json padded_sample = nullptr, int64_t num_padded = 0) { + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); } @@ -1308,7 +1308,7 @@ inline std::shared_ptr MindData(const std::string &dataset_file inline std::shared_ptr MindData(const std::string &dataset_file, const std::vector &columns_list, const std::reference_wrapper sampler, - nlohmann::json padded_sample = nullptr, int64_t num_padded = 0) { + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); } @@ -1325,7 +1325,7 @@ inline std::shared_ptr MindData(const std::string &dataset_file /// \return Shared pointer to the current MindDataDataset inline std::shared_ptr MindData( const std::vector &dataset_files, const std::vector &columns_list = {}, - const std::shared_ptr &sampler = std::make_shared(), nlohmann::json padded_sample = nullptr, + const std::shared_ptr &sampler = std::make_shared(), nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); @@ -1341,7 +1341,7 @@ inline std::shared_ptr MindData( /// \return Shared pointer to the current MindDataDataset inline std::shared_ptr MindData(const std::vector &dataset_files, const std::vector &columns_list, Sampler *sampler, - nlohmann::json padded_sample = nullptr, int64_t num_padded = 0) { + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); } @@ -1357,7 +1357,7 @@ inline std::shared_ptr MindData(const std::vector inline std::shared_ptr MindData(const std::vector &dataset_files, const std::vector &columns_list, const std::reference_wrapper sampler, - nlohmann::json padded_sample = nullptr, int64_t num_padded = 0) { + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded); } diff --git a/tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc b/tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc index a63d73a104..ee60aa9184 100644 --- a/tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc +++ b/tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc @@ -289,7 +289,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess7) { std::string file_path1 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; std::vector file_list = {file_path1}; std::shared_ptr ds = - MindData(file_list, {"file_name", "label"}, std::make_shared(), pad, 4); + MindData(file_list, {"file_name", "label"}, std::make_shared(), &pad, 4); EXPECT_NE(ds, nullptr); // Create a Skip operation on ds, skip original data in mindrecord and get padded samples @@ -341,7 +341,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess8) { std::string file_path1 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; std::vector file_list = {file_path1}; std::shared_ptr ds = - MindData(file_list, {"file_name", "label"}, std::make_shared(), pad, 4); + MindData(file_list, {"file_name", "label"}, std::make_shared(), &pad, 4); EXPECT_NE(ds, nullptr); std::vector types = ToDETypes(ds->GetOutputTypes()); @@ -412,13 +412,13 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess9) { std::string file_path1 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; std::vector file_list = {file_path1}; std::shared_ptr ds1 = - MindData(file_list, {"file_name", "label"}, std::make_shared(), pad, 4); + MindData(file_list, {"file_name", "label"}, std::make_shared(), &pad, 4); EXPECT_NE(ds1, nullptr); ds1 = ds1->Skip(5); EXPECT_NE(ds1, nullptr); std::shared_ptr ds2 = - MindData(file_list, {"file_name", "label"}, std::make_shared(), pad, 4); + MindData(file_list, {"file_name", "label"}, std::make_shared(), &pad, 4); EXPECT_NE(ds2, nullptr); ds2 = ds2->Skip(5); EXPECT_NE(ds2, nullptr); @@ -588,7 +588,7 @@ TEST_F(MindDataTestPipeline, TestMindDataFail4) { // Create a MindData Dataset std::string file_path2 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; - std::shared_ptr ds2 = MindData(file_path2, {"label"}, std::make_shared(), pad, -2); + std::shared_ptr ds2 = MindData(file_path2, {"label"}, std::make_shared(), &pad, -2); EXPECT_NE(ds2, nullptr); // Create an iterator over the result of the above dataset @@ -598,7 +598,7 @@ TEST_F(MindDataTestPipeline, TestMindDataFail4) { // Create a MindData Dataset std::string file_path3 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; - std::shared_ptr ds3 = MindData(file_path3, {}, std::make_shared(), pad, 1); + std::shared_ptr ds3 = MindData(file_path3, {}, std::make_shared(), &pad, 1); EXPECT_NE(ds3, nullptr); // Create an iterator over the result of the above dataset @@ -614,7 +614,7 @@ TEST_F(MindDataTestPipeline, TestMindDataFail4) { // Create a MindData Dataset std::string file_path4 = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0"; std::shared_ptr ds4 = - MindData(file_path4, {"file_name", "label"}, std::make_shared(), pad2, 1); + MindData(file_path4, {"file_name", "label"}, std::make_shared(), &pad2, 1); EXPECT_NE(ds4, nullptr); // Create an iterator over the result of the above dataset