You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

x86-example.cc 1.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <string>
  17. #include <memory>
  18. #include "minddata/dataset/include/dataset/datasets.h"
  19. using Dataset = mindspore::dataset::Dataset;
  20. using Iterator = mindspore::dataset::Iterator;
  21. using mindspore::dataset::Cifar10;
  22. using mindspore::dataset::RandomSampler;
  23. using mindspore::dataset::Tensor;
  24. int main() {
  25. MS_LOG(INFO) << "Doing MindDataTestPipeline-TestCifar10Dataset.";
  26. // Create a Cifar10 Dataset
  27. std::string folder_path = "./testCifar10Data/";
  28. std::shared_ptr<Dataset> ds = Cifar10(folder_path, std::string(), RandomSampler(false, 10));
  29. // Create an iterator over the result of the above dataset
  30. // This will trigger the creation of the Execution Tree and launch it.
  31. std::shared_ptr<Iterator> iter = ds->CreateIterator();
  32. // Iterate the dataset and get each row
  33. std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
  34. iter->GetNextRow(&row);
  35. uint64_t i = 0;
  36. while (row.size() != 0) {
  37. i++;
  38. auto image = row["image"];
  39. MS_LOG(INFO) << "Tensor image shape: " << image->shape();
  40. iter->GetNextRow(&row);
  41. }
  42. // Manually terminate the pipeline
  43. iter->Stop();
  44. }