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.

image_folder_op_test.cc 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. /**
  2. * Copyright 2019-2021 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 <iostream>
  17. #include <memory>
  18. #include <string>
  19. #include "common/common.h"
  20. #include "utils/ms_utils.h"
  21. #include "minddata/dataset/core/client.h"
  22. #include "minddata/dataset/core/global_context.h"
  23. #include "minddata/dataset/engine/datasetops/source/image_folder_op.h"
  24. #include "minddata/dataset/engine/datasetops/source/sampler/distributed_sampler.h"
  25. #include "minddata/dataset/engine/datasetops/source/sampler/pk_sampler.h"
  26. #include "minddata/dataset/engine/datasetops/source/sampler/random_sampler.h"
  27. #include "minddata/dataset/engine/datasetops/source/sampler/sampler.h"
  28. #include "minddata/dataset/engine/datasetops/source/sampler/sequential_sampler.h"
  29. #include "minddata/dataset/engine/datasetops/source/sampler/subset_random_sampler.h"
  30. #include "minddata/dataset/engine/datasetops/source/sampler/weighted_random_sampler.h"
  31. #include "minddata/dataset/util/status.h"
  32. #include "gtest/gtest.h"
  33. #include "utils/log_adapter.h"
  34. #include "securec.h"
  35. namespace common = mindspore::common;
  36. using namespace mindspore::dataset;
  37. using mindspore::LogStream;
  38. using mindspore::ExceptionType::NoExceptionType;
  39. using mindspore::MsLogLevel::ERROR;
  40. std::shared_ptr<BatchOp> Batch(int batch_size = 1, bool drop = false);
  41. std::shared_ptr<RepeatOp> Repeat(int repeat_cnt);
  42. std::shared_ptr<ExecutionTree> Build(std::vector<std::shared_ptr<DatasetOp>> ops);
  43. std::shared_ptr<ImageFolderOp> ImageFolder(int64_t num_works, int64_t rows, int64_t conns, std::string path,
  44. bool shuf = false, std::shared_ptr<SamplerRT> sampler = nullptr,
  45. std::map<std::string, int32_t> map = {}, bool decode = false) {
  46. std::shared_ptr<ImageFolderOp> so;
  47. ImageFolderOp::Builder builder;
  48. Status rc = builder.SetNumWorkers(num_works)
  49. .SetImageFolderDir(path)
  50. .SetOpConnectorSize(conns)
  51. .SetExtensions({".jpg", ".JPEG"})
  52. .SetSampler(std::move(sampler))
  53. .SetClassIndex(map)
  54. .SetDecode(decode)
  55. .Build(&so);
  56. if (rc.IsError()) {
  57. MS_LOG(ERROR) << "Fail to build ImageFolderOp: " << rc.ToString() << "\n";
  58. }
  59. return so;
  60. }
  61. Status Create1DTensor(std::shared_ptr<Tensor> *sample_ids, int64_t num_elements, unsigned char *data = nullptr,
  62. DataType::Type data_type = DataType::DE_UINT32) {
  63. TensorShape shape(std::vector<int64_t>(1, num_elements));
  64. RETURN_IF_NOT_OK(Tensor::CreateFromMemory(shape, DataType(data_type), data, sample_ids));
  65. return Status::OK();
  66. }
  67. class MindDataTestImageFolderSampler : public UT::DatasetOpTesting {
  68. protected:
  69. };
  70. TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeat) {
  71. std::string folder_path = datasets_root_path_ + "/testPK/data";
  72. auto op1 = ImageFolder(16, 2, 32, folder_path, false);
  73. auto op2 = Repeat(2);
  74. op1->set_total_repeats(2);
  75. op1->set_num_repeats_per_epoch(2);
  76. auto tree = Build({op1, op2});
  77. tree->Prepare();
  78. int32_t res[] = {0, 1, 2, 3};
  79. Status rc = tree->Launch();
  80. if (rc.IsError()) {
  81. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  82. EXPECT_TRUE(false);
  83. } else {
  84. DatasetIterator di(tree);
  85. TensorMap tensor_map;
  86. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  87. EXPECT_TRUE(rc.IsOk());
  88. uint64_t i = 0;
  89. int32_t label = 0;
  90. while (tensor_map.size() != 0) {
  91. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  92. EXPECT_TRUE(res[(i % 44) / 11] == label);
  93. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  94. i++;
  95. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  96. }
  97. EXPECT_TRUE(i == 88);
  98. }
  99. }
  100. TEST_F(MindDataTestImageFolderSampler, TestRandomImageFolder) {
  101. std::string folder_path = datasets_root_path_ + "/testPK/data";
  102. auto tree = Build({ImageFolder(16, 2, 32, folder_path, true, nullptr)});
  103. tree->Prepare();
  104. Status rc = tree->Launch();
  105. if (rc.IsError()) {
  106. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  107. EXPECT_TRUE(false);
  108. } else {
  109. DatasetIterator di(tree);
  110. TensorMap tensor_map;
  111. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  112. EXPECT_TRUE(rc.IsOk());
  113. uint64_t i = 0;
  114. int32_t label = 0;
  115. while (tensor_map.size() != 0) {
  116. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  117. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  118. i++;
  119. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  120. }
  121. EXPECT_TRUE(i == 44);
  122. }
  123. }
  124. TEST_F(MindDataTestImageFolderSampler, TestRandomSamplerImageFolder) {
  125. int32_t original_seed = GlobalContext::config_manager()->seed();
  126. GlobalContext::config_manager()->set_seed(0);
  127. int64_t num_samples = 12;
  128. std::shared_ptr<SamplerRT> sampler = std::make_unique<RandomSamplerRT>(true, num_samples, true);
  129. int32_t res[] = {2, 2, 2, 3, 2, 3, 2, 3, 1, 2, 2, 1}; // ground truth label
  130. std::string folder_path = datasets_root_path_ + "/testPK/data";
  131. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(sampler))});
  132. tree->Prepare();
  133. Status rc = tree->Launch();
  134. if (rc.IsError()) {
  135. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  136. EXPECT_TRUE(false);
  137. } else {
  138. DatasetIterator di(tree);
  139. TensorMap tensor_map;
  140. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  141. EXPECT_TRUE(rc.IsOk());
  142. uint64_t i = 0;
  143. int32_t label = 0;
  144. while (tensor_map.size() != 0) {
  145. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  146. EXPECT_TRUE(res[i] == label);
  147. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  148. i++;
  149. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  150. }
  151. EXPECT_TRUE(i == 12);
  152. }
  153. GlobalContext::config_manager()->set_seed(original_seed);
  154. }
  155. TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeatBatch) {
  156. std::string folder_path = datasets_root_path_ + "/testPK/data";
  157. auto op1 = ImageFolder(16, 2, 32, folder_path, false);
  158. auto op2 = Repeat(2);
  159. auto op3 = Batch(11);
  160. op1->set_total_repeats(2);
  161. op1->set_num_repeats_per_epoch(2);
  162. auto tree = Build({op1, op2, op3});
  163. tree->Prepare();
  164. int32_t res[4][11] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  165. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  166. {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
  167. {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}};
  168. Status rc = tree->Launch();
  169. if (rc.IsError()) {
  170. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  171. EXPECT_TRUE(false);
  172. } else {
  173. DatasetIterator di(tree);
  174. TensorMap tensor_map;
  175. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  176. EXPECT_TRUE(rc.IsOk());
  177. uint64_t i = 0;
  178. while (tensor_map.size() != 0) {
  179. std::shared_ptr<Tensor> label;
  180. Create1DTensor(&label, 11, reinterpret_cast<unsigned char *>(res[i % 4]), DataType::DE_INT32);
  181. EXPECT_TRUE((*label) == (*tensor_map["label"]));
  182. MS_LOG(DEBUG) << "row: " << i << " " << tensor_map["image"]->shape() << " (*label):" << (*label)
  183. << " *tensor_map[label]: " << *tensor_map["label"] << std::endl;
  184. i++;
  185. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  186. }
  187. EXPECT_TRUE(i == 8);
  188. }
  189. }
  190. TEST_F(MindDataTestImageFolderSampler, TestSubsetRandomSamplerImageFolder) {
  191. // id range 0 - 10 is label 0, and id range 11 - 21 is label 1
  192. std::vector<int64_t> indices({0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 11});
  193. int64_t num_samples = 0;
  194. std::shared_ptr<SamplerRT> sampler = std::make_shared<SubsetRandomSamplerRT>(indices, num_samples);
  195. std::string folder_path = datasets_root_path_ + "/testPK/data";
  196. // Expect 6 samples for label 0 and 1
  197. int res[2] = {6, 6};
  198. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(sampler))});
  199. tree->Prepare();
  200. Status rc = tree->Launch();
  201. if (rc.IsError()) {
  202. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  203. EXPECT_TRUE(false);
  204. } else {
  205. DatasetIterator di(tree);
  206. TensorMap tensor_map;
  207. rc = di.GetNextAsMap(&tensor_map);
  208. EXPECT_TRUE(rc.IsOk());
  209. uint64_t i = 0;
  210. int32_t label = 0;
  211. while (tensor_map.size() != 0) {
  212. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  213. res[label]--;
  214. i++;
  215. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  216. }
  217. EXPECT_EQ(res[0], 0);
  218. EXPECT_EQ(res[1], 0);
  219. EXPECT_TRUE(i == 12);
  220. }
  221. }
  222. TEST_F(MindDataTestImageFolderSampler, TestWeightedRandomSamplerImageFolder) {
  223. // num samples to draw.
  224. int64_t num_samples = 12;
  225. int64_t total_samples = 44;
  226. int64_t samples_per_tensor = 10;
  227. std::vector<double> weights(total_samples, std::rand() % 100);
  228. // create sampler with replacement = replacement
  229. std::shared_ptr<SamplerRT> sampler =
  230. std::make_shared<WeightedRandomSamplerRT>(weights, num_samples, true, samples_per_tensor);
  231. std::string folder_path = datasets_root_path_ + "/testPK/data";
  232. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(sampler))});
  233. tree->Prepare();
  234. Status rc = tree->Launch();
  235. if (rc.IsError()) {
  236. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  237. EXPECT_TRUE(false);
  238. } else {
  239. DatasetIterator di(tree);
  240. TensorMap tensor_map;
  241. rc = di.GetNextAsMap(&tensor_map);
  242. EXPECT_TRUE(rc.IsOk());
  243. uint64_t i = 0;
  244. int32_t label = 0;
  245. while (tensor_map.size() != 0) {
  246. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  247. i++;
  248. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  249. }
  250. EXPECT_TRUE(i == 12);
  251. }
  252. }
  253. TEST_F(MindDataTestImageFolderSampler, TestImageFolderClassIndex) {
  254. std::string folder_path = datasets_root_path_ + "/testPK/data";
  255. std::map<std::string, int32_t> map;
  256. map["class3"] = 333;
  257. map["class1"] = 111;
  258. map["wrong folder name"] = 1234; // this is skipped
  259. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, nullptr, map)});
  260. int64_t res[2] = {111, 333};
  261. tree->Prepare();
  262. Status rc = tree->Launch();
  263. if (rc.IsError()) {
  264. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  265. EXPECT_TRUE(false);
  266. } else {
  267. DatasetIterator di(tree);
  268. TensorMap tensor_map;
  269. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  270. EXPECT_TRUE(rc.IsOk());
  271. uint64_t i = 0;
  272. int32_t label = 0;
  273. while (tensor_map.size() != 0) {
  274. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  275. EXPECT_TRUE(label == res[i / 11]);
  276. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  277. i++;
  278. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  279. }
  280. EXPECT_TRUE(i == 22);
  281. }
  282. }
  283. TEST_F(MindDataTestImageFolderSampler, TestDistributedSampler) {
  284. int64_t num_samples = 0;
  285. std::shared_ptr<SamplerRT> sampler = std::make_shared<DistributedSamplerRT>(11, 10, false, num_samples);
  286. std::string folder_path = datasets_root_path_ + "/testPK/data";
  287. auto op1 = ImageFolder(16, 2, 32, folder_path, false, std::move(sampler));
  288. auto op2 = Repeat(4);
  289. op1->set_total_repeats(4);
  290. op1->set_num_repeats_per_epoch(4);
  291. auto tree = Build({op1, op2});
  292. tree->Prepare();
  293. Status rc = tree->Launch();
  294. if (rc.IsError()) {
  295. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  296. EXPECT_TRUE(false);
  297. } else {
  298. DatasetIterator di(tree);
  299. TensorMap tensor_map;
  300. rc = di.GetNextAsMap(&tensor_map);
  301. EXPECT_TRUE(rc.IsOk());
  302. uint64_t i = 0;
  303. int32_t label = 0;
  304. while (tensor_map.size() != 0) {
  305. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  306. EXPECT_EQ(i % 4, label);
  307. MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
  308. i++;
  309. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  310. }
  311. EXPECT_TRUE(i == 16);
  312. }
  313. }
  314. TEST_F(MindDataTestImageFolderSampler, TestPKSamplerImageFolder) {
  315. int64_t num_samples = 0;
  316. std::shared_ptr<SamplerRT> sampler = std::make_shared<PKSamplerRT>(3, false, num_samples, 4);
  317. int32_t res[] = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3}; // ground truth label
  318. std::string folder_path = datasets_root_path_ + "/testPK/data";
  319. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(sampler))});
  320. tree->Prepare();
  321. Status rc = tree->Launch();
  322. if (rc.IsError()) {
  323. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  324. EXPECT_TRUE(false);
  325. } else {
  326. DatasetIterator di(tree);
  327. TensorMap tensor_map;
  328. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  329. EXPECT_TRUE(rc.IsOk());
  330. uint64_t i = 0;
  331. int32_t label = 0;
  332. while (tensor_map.size() != 0) {
  333. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  334. EXPECT_TRUE(res[i] == label);
  335. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  336. i++;
  337. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  338. }
  339. EXPECT_TRUE(i == 12);
  340. }
  341. }
  342. TEST_F(MindDataTestImageFolderSampler, TestImageFolderDecode) {
  343. std::string folder_path = datasets_root_path_ + "/testPK/data";
  344. std::map<std::string, int32_t> map;
  345. map["class3"] = 333;
  346. map["class1"] = 111;
  347. map["wrong folder name"] = 1234; // this is skipped
  348. int64_t num_samples = 20;
  349. int64_t start_index = 0;
  350. auto seq_sampler = std::make_shared<SequentialSamplerRT>(start_index, num_samples);
  351. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(seq_sampler), map, true)});
  352. int64_t res[2] = {111, 333};
  353. tree->Prepare();
  354. Status rc = tree->Launch();
  355. if (rc.IsError()) {
  356. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  357. EXPECT_TRUE(false);
  358. } else {
  359. DatasetIterator di(tree);
  360. TensorMap tensor_map;
  361. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  362. EXPECT_TRUE(rc.IsOk());
  363. uint64_t i = 0;
  364. int32_t label = 0;
  365. while (tensor_map.size() != 0) {
  366. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  367. EXPECT_TRUE(label == res[i / 11]);
  368. EXPECT_TRUE(tensor_map["image"]->shape() ==
  369. TensorShape({2268, 4032, 3})); // verify shapes are correct after decode
  370. MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
  371. i++;
  372. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  373. }
  374. EXPECT_TRUE(i == 20);
  375. }
  376. }
  377. TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding1) {
  378. int64_t num_samples = 5;
  379. std::shared_ptr<SamplerRT> sampler = std::make_shared<DistributedSamplerRT>(4, 0, false, num_samples);
  380. std::string folder_path = datasets_root_path_ + "/testPK/data";
  381. // numWrks, rows, conns, path, shuffle, sampler, map, numSamples, decode
  382. auto tree = Build({ImageFolder(16, 2, 32, folder_path, false, std::move(sampler), {})});
  383. tree->Prepare();
  384. Status rc = tree->Launch();
  385. int32_t labels[5] = {0, 0, 0, 1, 1};
  386. if (rc.IsError()) {
  387. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  388. EXPECT_TRUE(false);
  389. } else {
  390. DatasetIterator di(tree);
  391. TensorMap tensor_map;
  392. rc = di.GetNextAsMap(&tensor_map);
  393. EXPECT_TRUE(rc.IsOk());
  394. uint64_t i = 0;
  395. int32_t label = 0;
  396. while (tensor_map.size() != 0) {
  397. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  398. EXPECT_EQ(labels[i], label);
  399. MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
  400. i++;
  401. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  402. }
  403. EXPECT_TRUE(i == 5);
  404. }
  405. }
  406. TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding2) {
  407. int64_t num_samples = 12;
  408. std::shared_ptr<SamplerRT> sampler = std::make_shared<DistributedSamplerRT>(4, 3, false, num_samples);
  409. std::string folder_path = datasets_root_path_ + "/testPK/data";
  410. // numWrks, rows, conns, path, shuffle, sampler, map, numSamples, decode
  411. auto tree = Build({ImageFolder(16, 16, 32, folder_path, false, std::move(sampler), {})});
  412. tree->Prepare();
  413. Status rc = tree->Launch();
  414. uint32_t labels[11] = {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3};
  415. if (rc.IsError()) {
  416. MS_LOG(ERROR) << "Return code error detected during tree launch: " << common::SafeCStr(rc.ToString()) << ".";
  417. EXPECT_TRUE(false);
  418. } else {
  419. DatasetIterator di(tree);
  420. TensorMap tensor_map;
  421. rc = di.GetNextAsMap(&tensor_map);
  422. EXPECT_TRUE(rc.IsOk());
  423. uint64_t i = 0;
  424. int32_t label = 0;
  425. while (tensor_map.size() != 0) {
  426. tensor_map["label"]->GetItemAt<int32_t>(&label, {});
  427. EXPECT_EQ(labels[i], label);
  428. MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
  429. i++;
  430. ASSERT_OK(di.GetNextAsMap(&tensor_map));
  431. }
  432. EXPECT_TRUE(i == 11);
  433. }
  434. }