2020-10-15 23:09:40 +08:00
|
|
|
/**
|
2021-02-25 06:24:11 +08:00
|
|
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
2020-10-15 23:09:40 +08:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "minddata/dataset/engine/tree_adapter.h"
|
|
|
|
|
#include "common/common.h"
|
|
|
|
|
#include "minddata/dataset/core/tensor_row.h"
|
2021-04-17 15:44:57 +08:00
|
|
|
#include "minddata/dataset/include/dataset/datasets.h"
|
|
|
|
|
#include "minddata/dataset/include/dataset/transforms.h"
|
2020-10-15 23:09:40 +08:00
|
|
|
|
2020-10-22 03:21:56 +08:00
|
|
|
// IR non-leaf nodes
|
|
|
|
|
#include "minddata/dataset/engine/ir/datasetops/bucket_batch_by_length_node.h"
|
|
|
|
|
|
2021-10-28 05:03:57 +08:00
|
|
|
#include "minddata/dataset/engine/tree_modifier.h"
|
2021-12-14 03:46:39 +08:00
|
|
|
#include "minddata/dataset/engine/serdes.h"
|
2021-10-28 05:03:57 +08:00
|
|
|
|
2020-10-15 23:09:40 +08:00
|
|
|
using namespace mindspore::dataset;
|
|
|
|
|
using mindspore::dataset::Tensor;
|
|
|
|
|
|
2021-12-14 03:46:39 +08:00
|
|
|
class MindDataTestTreeAdapter : public UT::DatasetOpTesting {};
|
2020-10-15 23:09:40 +08:00
|
|
|
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestSimpleTreeAdapter) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestTreeAdapter-TestSimpleTreeAdapter.";
|
|
|
|
|
|
|
|
|
|
// Create a Mnist Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/";
|
2021-02-25 06:24:11 +08:00
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, "all", std::make_shared<SequentialSampler>(0, 4));
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
ds = ds->Batch(2);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
auto tree_adapter = std::make_shared<TreeAdapter>();
|
|
|
|
|
|
|
|
|
|
// Disable IR optimization pass
|
|
|
|
|
tree_adapter->SetOptimize(false);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
Status rc = tree_adapter->Compile(ds->IRNode(), 1);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
|
|
|
|
|
const std::unordered_map<std::string, int32_t> map = {{"label", 1}, {"image", 0}};
|
2021-09-23 08:28:29 +08:00
|
|
|
EXPECT_EQ(tree_adapter->GetColumnNameMap(), map);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
std::vector<size_t> row_sizes = {2, 2, 0};
|
2020-10-15 23:09:40 +08:00
|
|
|
|
|
|
|
|
TensorRow row;
|
|
|
|
|
for (size_t sz : row_sizes) {
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
EXPECT_EQ(row.size(), sz);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_TRUE(rc.IsError());
|
|
|
|
|
const std::string err_msg = rc.ToString();
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
EXPECT_TRUE(err_msg.find("EOF buffer encountered.") != err_msg.npos);
|
2020-10-15 23:09:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestTreeAdapterWithRepeat) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestTreeAdapter-TestTreeAdapterWithRepeat.";
|
|
|
|
|
|
|
|
|
|
// Create a Mnist Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/";
|
2021-02-25 06:24:11 +08:00
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, "all", std::make_shared<SequentialSampler>(0, 3));
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
ds = ds->Batch(2, false);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
auto tree_adapter = std::make_shared<TreeAdapter>();
|
2020-10-15 23:09:40 +08:00
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
Status rc = tree_adapter->Compile(ds->IRNode(), 2);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
const std::unordered_map<std::string, int32_t> map = tree_adapter->GetColumnNameMap();
|
|
|
|
|
EXPECT_EQ(tree_adapter->GetColumnNameMap(), map);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
std::vector<size_t> row_sizes = {2, 2, 0, 2, 2, 0};
|
2020-10-15 23:09:40 +08:00
|
|
|
|
|
|
|
|
TensorRow row;
|
|
|
|
|
for (size_t sz : row_sizes) {
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
EXPECT_EQ(row.size(), sz);
|
|
|
|
|
}
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
const std::string err_msg = rc.ToString();
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
EXPECT_TRUE(err_msg.find("EOF buffer encountered.") != err_msg.npos);
|
2020-10-15 23:09:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestProjectMapTreeAdapter) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestProjectMap.";
|
|
|
|
|
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
2021-02-25 06:24:11 +08:00
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<SequentialSampler>(0, 2));
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
2021-02-12 04:20:11 +08:00
|
|
|
std::shared_ptr<TensorTransform> one_hot = std::make_shared<transforms::OneHot>(10);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_NE(one_hot, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation, this will automatically add a project after map
|
|
|
|
|
ds = ds->Map({one_hot}, {"label"}, {"label"}, {"label"});
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
2021-09-23 08:28:29 +08:00
|
|
|
auto tree_adapter = std::make_shared<TreeAdapter>();
|
|
|
|
|
|
|
|
|
|
Status rc = tree_adapter->Compile(ds->IRNode(), 2);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
|
|
|
|
|
const std::unordered_map<std::string, int32_t> map = {{"label", 0}};
|
2021-09-23 08:28:29 +08:00
|
|
|
EXPECT_EQ(tree_adapter->GetColumnNameMap(), map);
|
2020-10-15 23:09:40 +08:00
|
|
|
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
std::vector<size_t> row_sizes = {1, 1, 0, 1, 1, 0};
|
2020-10-15 23:09:40 +08:00
|
|
|
TensorRow row;
|
|
|
|
|
|
|
|
|
|
for (size_t sz : row_sizes) {
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
EXPECT_TRUE(rc.IsOk());
|
|
|
|
|
EXPECT_EQ(row.size(), sz);
|
|
|
|
|
}
|
2021-09-23 08:28:29 +08:00
|
|
|
rc = tree_adapter->GetNext(&row);
|
2020-10-15 23:09:40 +08:00
|
|
|
const std::string err_msg = rc.ToString();
|
added python api based on cpp api
1st draft of python iterator
Added Cifar10 and Cifar100 pybind port
Change pybind to use IR for Skip and Manifest
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
DatasetNode as a base for all IR nodes
namespace change
Fix the namespace issue and make ut tests work
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Add VOCDataset
!63 Added RandomDataset
* Added RandomDataset
add imagefolder ir
Pybind switch: CelebA and UT
!61 CLUE example with class definition
* Merge branch 'python-api' of gitee.com:ezphlow/mindspore into clue_class_pybind
* Passing testcases
* Added CLUE, not working
add ManifestDataset IR
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
Update Coco & VOC & TFReader, Update clang-format, Reorder
datasets_binding
!69 Add Generator and move c_dataset.Iterator to dataset.Iterator
* Add GeneratorDataset to c_dataset
* Add GeneratorDataset to c_dataset
!67 Moving c_datasets and adding sampler wrapper
* Need to add create() method in datasets.py
* migration from c_dataset to dataset part 1
!71 Fix indent error
* Fix indentation error
!72 Fix c_api tests cases
* Fix c_api tests cases
!73 Added CSV Dataset
* Added CSVDataset
pybind switch: Take and CelebA fixes
!75 move c_dataset functionality to datasets
* Fixed existing testcases
* Added working clue and imagefolder
* Added sampler conversion from pybind
* Added sampler creation
!77 Add Python API tree
* Python API tree
add minddataset
TextFileDataset pybind
Rename to skip test_concat.py and test_minddataset_exception.py
!80 Add batch IR to python-api branch, most test cases work
* staging III
* staging, add pybind
Enable more c_api take and CelebA tests; delete util_c_api
!84 Schema changes in datasets.py
* Schema changes
!85 Remove input_indexes from sub-classes
* remove input_index from each subclass
!83 Remove C datasets
* Removed c_dataset package
* Remove c_datasets
!82 pybind switch: shuffle
* pybind switch: shuffle
!86 Add build_vocab
* Add build_vocab
Rebase with upstream/master
_shuffle conflict
BatchNode error
!88 Fix rebase problem
* fix rebase problem
Enable more unit tests; code typo/nit fixes
!91 Fix python vocag hang
* Fix python vocab hang
!89 Added BucketBatchByLength Pybind switch
* Added BucketBatchByLength
Update and enable more tet_c_api_*.py tests
!95 Add BuildSentencePeiceVocab
* - Add BuildSentencePeiceVocab
!96 Fix more tests
* - Fix some tests
- Enable more test_c_api_*
- Add syncwait
!99 pybind switch for device op
* pybind switch for device op
!93 Add getters to python API
* Add getters to python API
!101 Validate tree, error if graph
* - Add sync wait
!103 TFrecord/Random Datasets schema problem
* - TfRecord/Random schem aproblem
!102 Added filter pybind switch
* Added Filter pybind switch
!104 Fix num_samples
* - TfRecord/Random schem aproblem
!105 Fix to_device hang
* Fix to_device hang
!94 Adds Cache support for CLUE dataset
* Added cache for all dataset ops
* format change
* Added CLUE cache support
* Added Cache conversion
Add save pybind
fix compile err
init modify concat_node
!107 Fix some tests cases
* Fix tests cases
Enable and fix more tests
!109 pybind switch for get dataset size
* pybind_get_dataset_size
some check-code fixes for pylint, cpplint and clang-format
!113 Add callback
* revert
* dataset_sz 1 line
* fix typo
* get callback to work
!114 Make Android compile clean
* Make Android Compile Clean
Fix build issues due to rebase
!115 Fix more tests
* Fix tests cases
* !93 Add getters to python API
fix test_profiling.py
!116 fix get dataset size
* fix get dataset size
!117 GetColumnNames pybind switch
* Added GetColumnNames pybind switch
code-check fixes: clangformat, cppcheck, cpplint, pylint
Delete duplicate test_c_api_*.py files; more lint fixes
!121 Fix cpp tests
* Remove extra call to getNext in cpp tests
!122 Fix Schema with Generator
* Fix Schema with Generator
fix some cases of csv & mindrecord
!124 fix tfrecord get_dataset_size and add some UTs
* fix tfrecord get dataset size and add some ut for get_dataset_size
!125 getter separation
* Getter separation
!126 Fix sampler.GetNumSamples
* Fix sampler.GetNumSampler
!127 Assign runtime getter to each get function
* Assign runtime getter to each get function
Fix compile issues
!128 Match master code
* Match master code
!129 Cleanup DeviceOp/save code
* Cleanup ToDevice/Save code
!130 Add cache fix
* Added cache fix for map and image folder
!132 Fix testing team issues
* Pass queue_name from python to C++
* Add Schema.from_json
!131 Fix Cache op issues and delete de_pipeline
* Roll back C++ change
* Removed de_pipeline and passing all cache tests.
* fixed cache tests
!134 Cleanup datasets.py part1
* Cleanup dataset.py part1
!133 Updated validation for SentencePieceVocab.from_dataset
* Added type_check for column names in SentencePieceVocab.from_dataset
Rebase on master 181120 10:20
fix profiling
temporary solution of catching stauts from Node.Build()
!141 ToDevice Termination
* ToDevice termination
pylint fixes
!137 Fix test team issues and add some corresponding tests
* Fix test team issues and add some corresponding tests
!138 TreeGetter changes to use OptPass
* Getter changes to use OptPass (Zirui)
Rebase fix
!143 Fix cpplint issue
* Fix cpplint issue
pylint fixes in updated testcases
!145 Reset exceptions testcase
* reset exception test to master
!146 Fix Check_Pylint Error
* Fix Check_Pylint Error
!147 fix android
* fix android
!148 ToDevice changes
* Add ToDevice to the iterator List for cleanup at exit
!149 Pylint issue
* Add ToDevice to the iterator List for cleanup at exit
!150 Pylint 2
* Add ToDevice to the iterator List for cleanup at exit
!152 ExecutionTree error
* ET destructor error
!153 in getter_pass, only remove callback, without deleting map op
* getter pass no longer removes map
!156 early __del__ of iterator/to_device
* early __del__ of iterator
!155 Address review comments Eric 1
* Added one liner fix to validators.py
* roll back signature fix
* lint fix
* Eric Address comments 2
* C++ lint fix
* Address comments Eric 1
!158 Review rework for dataset bindings - part 1
* Reorder nodes repeat and rename
* Review rework for dataset bindings - part 1
!154 Fixing minor problems in the comments (datasets.py, python_tree_consumer.cc, iterators_bindings.cc, and iterators.py)
* Fixing minor problems in the comments (datasets.py, python_tree_consum…
!157 add replace none
* Add replace_none to datasets.py, address comments in tests
Trying to resolve copy
Override the deepcopy method of deviceop
Create_ir_tree method
Create_ir_tree method 2
Create_ir_tree method 2
del to_device if already exists
del to_device if already exists
cache getters shapes and types
Added yolov3 relaxation, to be rolled back
Get shapes and types together
bypass yolo
NumWorkers for MapOp
revert Yolo
revert Thor
Print more info
Debug code: Update LOG INFO to LOG ERROR
do not remove epochctrl for getter pass
Remove repeat(1)
pritn batch size
add log to tree_consumer and device_queue op
Revert PR 8744
Signed-off-by: alex-yuyue <yue.yu1@huawei.com>
__del__ toDEvice
__del__ toDevice2
!165 add ifndef ENABLE_ANDROID to device queue print
* Add ifndef ENABLE_ANDROID to device queue print
revert some changes
!166 getter: get_data_info
* getter: get_data_info
!168 add back tree print
* revert info to warnning in one log
* add back the missed print tree log
Release GIL in GetDataInfo
2020-07-17 05:34:09 +08:00
|
|
|
EXPECT_TRUE(err_msg.find("EOF buffer encountered.") != err_msg.npos);
|
2020-10-15 23:09:40 +08:00
|
|
|
}
|
2021-10-28 05:03:57 +08:00
|
|
|
|
2021-12-14 03:46:39 +08:00
|
|
|
// Feature: Test for Serializing and Deserializing an optimized IR Tree after the tree has been modified with
|
|
|
|
|
// TreeModifier or in other words through Autotune indirectly.
|
|
|
|
|
// Description: Create a simple tree, modify the workers and queue size, serialize the optimized IR Tree, obtain a new
|
|
|
|
|
// tree with deserialize and then compare the output of serializing the new optimized IR tree with the first tree.
|
|
|
|
|
// Expectation: No failures.
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestOptimizedTreeSerializeDeserializeForAutoTune) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestTreeAdapter-TestOptimizedTreeSerializeDeserializeForAutoTune.";
|
|
|
|
|
|
|
|
|
|
// Create a CSVDataset, with single CSV file
|
|
|
|
|
std::string train_file = datasets_root_path_ + "/testCSV/1.csv";
|
|
|
|
|
std::vector<std::string> column_names = {"col1", "col2", "col3", "col4"};
|
|
|
|
|
std::shared_ptr<Dataset> ds = CSV({train_file}, ',', {}, column_names, 0, ShuffleMode::kFalse);
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
ds = ds->Project({"col1"});
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
ds = ds->Repeat(2);
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
auto to_number = std::make_shared<text::ToNumber>(mindspore::DataType::kNumberTypeInt32);
|
|
|
|
|
ASSERT_NE(to_number, nullptr);
|
|
|
|
|
ds = ds->Map({to_number}, {"col1"}, {"col1"});
|
|
|
|
|
ds->SetNumWorkers(1);
|
|
|
|
|
ds = ds->Batch(1);
|
|
|
|
|
ds->SetNumWorkers(1);
|
|
|
|
|
|
|
|
|
|
// Create a tree adapter and compile the IR Tree
|
|
|
|
|
auto tree_adapter1 = std::make_shared<TreeAdapter>();
|
|
|
|
|
ASSERT_OK(tree_adapter1->Compile(ds->IRNode(), 1));
|
|
|
|
|
|
|
|
|
|
// Change num_parallel_workers and connector_queue_size for some ops
|
|
|
|
|
auto tree_modifier = std::make_unique<TreeModifier>(tree_adapter1.get());
|
|
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ChangeNumWorkersRequest>(10));
|
|
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ResizeConnectorRequest>(20));
|
|
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ResizeConnectorRequest>(100));
|
|
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>(10));
|
|
|
|
|
|
|
|
|
|
std::vector<int32_t> expected_result = {1, 5, 9, 1, 5, 9};
|
|
|
|
|
TensorRow row;
|
|
|
|
|
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
ASSERT_OK(tree_adapter1->GetNext(&row));
|
|
|
|
|
while (!row.empty()) {
|
|
|
|
|
auto tensor = row[0];
|
|
|
|
|
int32_t num;
|
|
|
|
|
ASSERT_OK(tensor->GetItemAt(&num, {0}));
|
|
|
|
|
EXPECT_EQ(num, expected_result[i]);
|
|
|
|
|
ASSERT_OK(tree_adapter1->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
// Expect 6 samples
|
|
|
|
|
EXPECT_EQ(i, 6);
|
|
|
|
|
|
|
|
|
|
// Serialize the optimized IR Tree
|
|
|
|
|
nlohmann::json out_json;
|
|
|
|
|
ASSERT_OK(Serdes::SaveToJSON(tree_adapter1->RootIRNode(), "", &out_json));
|
|
|
|
|
|
|
|
|
|
// Check that updated values of num_parallel_workers and connector_queue_size are not reflected in the json
|
|
|
|
|
EXPECT_EQ(out_json["op_type"], "Batch");
|
|
|
|
|
EXPECT_NE(out_json["num_parallel_workers"], 10);
|
|
|
|
|
EXPECT_NE(out_json["connector_queue_size"], 100);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(out_json["children"][0]["op_type"], "Map");
|
|
|
|
|
EXPECT_NE(out_json["children"][0]["num_parallel_workers"], 10);
|
|
|
|
|
EXPECT_NE(out_json["children"][0]["connector_queue_size"], 20);
|
|
|
|
|
|
|
|
|
|
// Create an op_id to dataset op mapping
|
|
|
|
|
std::map<int32_t, std::shared_ptr<DatasetOp>> op_mapping;
|
|
|
|
|
auto tree = tree_adapter1->GetExecutionTree();
|
|
|
|
|
ASSERT_NE(tree, nullptr);
|
|
|
|
|
|
|
|
|
|
for (auto itr = tree->begin(); itr != tree->end(); ++itr) {
|
|
|
|
|
op_mapping[itr->id()] = itr.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the serialized JSON object of the optimized IR tree
|
|
|
|
|
ASSERT_OK(Serdes::UpdateOptimizedIRTreeJSON(&out_json, op_mapping));
|
|
|
|
|
|
|
|
|
|
// Check that updated values of num_parallel_workers and connector_queue_size are reflected in the json now
|
|
|
|
|
EXPECT_EQ(out_json["op_type"], "Batch");
|
|
|
|
|
EXPECT_EQ(out_json["num_parallel_workers"], 10);
|
|
|
|
|
EXPECT_EQ(out_json["connector_queue_size"], 100);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(out_json["children"][0]["op_type"], "Map");
|
|
|
|
|
EXPECT_EQ(out_json["children"][0]["num_parallel_workers"], 10);
|
|
|
|
|
EXPECT_EQ(out_json["children"][0]["connector_queue_size"], 20);
|
|
|
|
|
|
|
|
|
|
// Deserialize the above updated serialized optimized IR Tree
|
|
|
|
|
std::shared_ptr<DatasetNode> deserialized_node;
|
|
|
|
|
ASSERT_OK(Serdes::ConstructPipeline(out_json, &deserialized_node));
|
|
|
|
|
|
|
|
|
|
// Create a new tree adapter and compile the IR Tree obtained from deserialization above
|
|
|
|
|
auto tree_adapter2 = std::make_shared<TreeAdapter>();
|
|
|
|
|
ASSERT_OK(tree_adapter2->Compile(deserialized_node, 1));
|
|
|
|
|
|
|
|
|
|
// Serialize the new optimized IR Tree
|
|
|
|
|
nlohmann::json out_json1;
|
|
|
|
|
ASSERT_OK(Serdes::SaveToJSON(tree_adapter2->RootIRNode(), "", &out_json1));
|
|
|
|
|
|
|
|
|
|
// Ensure that both the serialized outputs are equal
|
|
|
|
|
EXPECT_TRUE(out_json == out_json1);
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
ASSERT_OK(tree_adapter2->GetNext(&row));
|
|
|
|
|
while (!row.empty()) {
|
|
|
|
|
auto tensor = row[0];
|
|
|
|
|
int32_t num;
|
|
|
|
|
ASSERT_OK(tensor->GetItemAt(&num, {0}));
|
|
|
|
|
EXPECT_EQ(num, expected_result[i]);
|
|
|
|
|
ASSERT_OK(tree_adapter2->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expect 6 samples
|
|
|
|
|
EXPECT_EQ(i, 6);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-28 05:03:57 +08:00
|
|
|
// Feature: Basic test for TreeModifier
|
|
|
|
|
// Description: Create simple tree and modify the tree by adding workers, change queue size and then removing workers
|
|
|
|
|
// Expectation: No failures.
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestSimpleTreeModifier) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestTreeAdapter-TestSimpleTreeModifier.";
|
|
|
|
|
|
|
|
|
|
// Create a CSVDataset, with single CSV file
|
|
|
|
|
std::string train_file = datasets_root_path_ + "/testCSV/1.csv";
|
|
|
|
|
std::vector<std::string> column_names = {"col1", "col2", "col3", "col4"};
|
|
|
|
|
std::shared_ptr<Dataset> ds = CSV({train_file}, ',', {}, column_names, 0, ShuffleMode::kFalse);
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
ds = ds->Project({"col1"});
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
ds = ds->Repeat(2);
|
|
|
|
|
ASSERT_NE(ds, nullptr);
|
|
|
|
|
auto to_number = std::make_shared<text::ToNumber>(mindspore::DataType::kNumberTypeInt32);
|
|
|
|
|
ASSERT_NE(to_number, nullptr);
|
|
|
|
|
ds = ds->Map({to_number}, {"col1"}, {"col1"});
|
|
|
|
|
ds->SetNumWorkers(1);
|
2021-11-11 12:27:45 +08:00
|
|
|
ds = ds->Batch(1);
|
|
|
|
|
ds->SetNumWorkers(1);
|
2021-10-28 05:03:57 +08:00
|
|
|
|
|
|
|
|
auto tree_adapter = std::make_shared<TreeAdapter>();
|
|
|
|
|
// Disable IR optimization pass
|
|
|
|
|
tree_adapter->SetOptimize(false);
|
|
|
|
|
ASSERT_OK(tree_adapter->Compile(ds->IRNode(), 1));
|
|
|
|
|
|
|
|
|
|
auto tree_modifier = std::make_unique<TreeModifier>(tree_adapter.get());
|
2021-11-11 12:27:45 +08:00
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ChangeNumWorkersRequest>(2));
|
|
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ChangeNumWorkersRequest>());
|
|
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ChangeNumWorkersRequest>(10));
|
|
|
|
|
|
|
|
|
|
tree_modifier->AddChangeRequest(1, std::make_shared<ResizeConnectorRequest>(20));
|
|
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ResizeConnectorRequest>(100));
|
|
|
|
|
|
2021-10-28 05:03:57 +08:00
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>(2));
|
|
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>());
|
|
|
|
|
tree_modifier->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>(10));
|
|
|
|
|
|
|
|
|
|
std::vector<int32_t> expected_result = {1, 5, 9, 1, 5, 9};
|
|
|
|
|
TensorRow row;
|
|
|
|
|
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
ASSERT_OK(tree_adapter->GetNext(&row));
|
|
|
|
|
|
2021-12-14 03:46:39 +08:00
|
|
|
while (!row.empty()) {
|
2021-10-28 05:03:57 +08:00
|
|
|
auto tensor = row[0];
|
|
|
|
|
int32_t num;
|
2021-11-11 12:27:45 +08:00
|
|
|
ASSERT_OK(tensor->GetItemAt(&num, {0}));
|
2021-10-28 05:03:57 +08:00
|
|
|
EXPECT_EQ(num, expected_result[i]);
|
|
|
|
|
ASSERT_OK(tree_adapter->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expect 6 samples
|
|
|
|
|
EXPECT_EQ(i, 6);
|
2022-02-15 15:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Feature: Test for TreeModifier on MindDataset
|
|
|
|
|
// Description: Create a simple tree with a Mindrecord op first add then add and remove workers afterward. Collect
|
|
|
|
|
// file_name of images when executing the first tree and then compare the outputs of the other runs against it.
|
|
|
|
|
// Expectation: No failures.
|
|
|
|
|
TEST_F(MindDataTestTreeAdapter, TestTreeModifierMindRecord) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestTreeAdapter-TestTreeModifierMindRecord.";
|
|
|
|
|
|
|
|
|
|
// Create a MindData Dataset
|
|
|
|
|
// Pass one mindrecord shard file to parse dataset info, and search for other mindrecord files with same dataset info,
|
|
|
|
|
// thus all records in imagenet.mindrecord0 ~ imagenet.mindrecord3 will be read (we only collect "file_name" column).
|
|
|
|
|
std::string file_path = datasets_root_path_ + "/../mindrecord/testMindDataSet/testImageNetData/imagenet.mindrecord0";
|
|
|
|
|
std::shared_ptr<Dataset> ds = MindData(file_path, {"file_name"}, std::make_shared<SequentialSampler>(0, 20));
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
ds->SetNumWorkers(1);
|
|
|
|
|
|
|
|
|
|
TensorRow row;
|
|
|
|
|
std::vector<std::string> file_names;
|
|
|
|
|
|
|
|
|
|
auto tree_adapter = std::make_shared<TreeAdapter>();
|
|
|
|
|
// Disable IR optimization pass
|
|
|
|
|
tree_adapter->SetOptimize(false);
|
|
|
|
|
|
|
|
|
|
ASSERT_OK(tree_adapter->Compile(ds->IRNode(), 1));
|
|
|
|
|
// Iterate the dataset and collect the file_names in the dataset
|
|
|
|
|
ASSERT_OK(tree_adapter->GetNext(&row));
|
|
|
|
|
uint64_t i = 0;
|
2021-12-14 03:46:39 +08:00
|
|
|
while (!row.empty()) {
|
2022-02-15 15:35:26 +08:00
|
|
|
auto tensor = row[0];
|
|
|
|
|
std::string_view sv;
|
|
|
|
|
ASSERT_OK(tensor->GetItemAt(&sv, {}));
|
|
|
|
|
std::string image_name(sv);
|
|
|
|
|
file_names.push_back(image_name);
|
|
|
|
|
|
|
|
|
|
ASSERT_OK(tree_adapter->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
// Expect 20 samples
|
|
|
|
|
EXPECT_EQ(i, 20);
|
|
|
|
|
|
|
|
|
|
auto tree_adapter2 = std::make_shared<TreeAdapter>();
|
|
|
|
|
// Disable IR optimization pass
|
|
|
|
|
tree_adapter2->SetOptimize(false);
|
|
|
|
|
ASSERT_OK(tree_adapter2->Compile(ds->IRNode(), 1));
|
|
|
|
|
auto tree_modifier1 = std::make_unique<TreeModifier>(tree_adapter2.get());
|
|
|
|
|
// Change number of workers for MindDataset from 1 to 5
|
|
|
|
|
tree_modifier1->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>(5));
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
ASSERT_OK(tree_adapter2->GetNext(&row));
|
2021-12-14 03:46:39 +08:00
|
|
|
while (!row.empty()) {
|
2022-02-15 15:35:26 +08:00
|
|
|
auto tensor = row[0];
|
|
|
|
|
std::string_view sv;
|
|
|
|
|
ASSERT_OK(tensor->GetItemAt(&sv, {}));
|
|
|
|
|
std::string image_name(sv);
|
|
|
|
|
EXPECT_EQ(image_name, file_names[i]);
|
|
|
|
|
|
|
|
|
|
ASSERT_OK(tree_adapter2->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
// Expect 20 samples
|
|
|
|
|
EXPECT_EQ(i, 20);
|
|
|
|
|
|
|
|
|
|
auto tree_adapter3 = std::make_shared<TreeAdapter>();
|
|
|
|
|
// Disable IR optimization pass
|
|
|
|
|
tree_adapter3->SetOptimize(false);
|
|
|
|
|
ASSERT_OK(tree_adapter3->Compile(ds->IRNode(), 1));
|
|
|
|
|
auto tree_modifier2 = std::make_unique<TreeModifier>(tree_adapter3.get());
|
|
|
|
|
// Change number of workers for MindDataset from 5 to 2
|
|
|
|
|
tree_modifier2->AddChangeRequest(0, std::make_shared<ChangeNumWorkersRequest>(2));
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
ASSERT_OK(tree_adapter3->GetNext(&row));
|
2021-12-14 03:46:39 +08:00
|
|
|
while (!row.empty()) {
|
2022-02-15 15:35:26 +08:00
|
|
|
auto tensor = row[0];
|
|
|
|
|
std::string_view sv;
|
|
|
|
|
ASSERT_OK(tensor->GetItemAt(&sv, {}));
|
|
|
|
|
std::string image_name(sv);
|
|
|
|
|
EXPECT_EQ(image_name, file_names[i]);
|
|
|
|
|
|
|
|
|
|
ASSERT_OK(tree_adapter3->GetNext(&row));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
// Expect 20 samples
|
|
|
|
|
EXPECT_EQ(i, 20);
|
2021-12-14 03:46:39 +08:00
|
|
|
}
|