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.

voc_op_test.cc 2.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Copyright 2019 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 <fstream>
  17. #include <iostream>
  18. #include <memory>
  19. #include <string>
  20. #include "common/common.h"
  21. #include "common/utils.h"
  22. #include "dataset/core/client.h"
  23. #include "dataset/core/global_context.h"
  24. #include "dataset/engine/datasetops/source/voc_op.h"
  25. #include "dataset/engine/datasetops/source/sampler/distributed_sampler.h"
  26. #include "dataset/engine/datasetops/source/sampler/pk_sampler.h"
  27. #include "dataset/engine/datasetops/source/sampler/random_sampler.h"
  28. #include "dataset/engine/datasetops/source/sampler/sampler.h"
  29. #include "dataset/engine/datasetops/source/sampler/sequential_sampler.h"
  30. #include "dataset/engine/datasetops/source/sampler/subset_random_sampler.h"
  31. #include "dataset/engine/datasetops/source/sampler/weighted_random_sampler.h"
  32. #include "dataset/util/de_error.h"
  33. #include "dataset/util/path.h"
  34. #include "dataset/util/status.h"
  35. #include "gtest/gtest.h"
  36. #include "utils/log_adapter.h"
  37. #include "securec.h"
  38. namespace common = mindspore::common;
  39. using namespace mindspore::dataset;
  40. using mindspore::MsLogLevel::ERROR;
  41. using mindspore::ExceptionType::NoExceptionType;
  42. using mindspore::LogStream;
  43. std::shared_ptr<BatchOp> Batch(int batch_size = 1, bool drop = false, int rows_per_buf = 2);
  44. std::shared_ptr<RepeatOp> Repeat(int repeat_cnt);
  45. std::shared_ptr<ExecutionTree> Build(std::vector<std::shared_ptr<DatasetOp>> ops);
  46. std::shared_ptr<VOCOp> CreateVOC(int64_t num_wrks, int64_t rows, int64_t conns, std::string path,
  47. bool shuf = false, std::unique_ptr<Sampler> sampler = nullptr,
  48. int64_t num_samples = 0, bool decode = false) {
  49. std::shared_ptr<VOCOp> so;
  50. VOCOp::Builder builder;
  51. Status rc = builder.SetNumWorkers(num_wrks).SetDir(path).SetRowsPerBuffer(rows)
  52. .SetOpConnectorSize(conns).SetSampler(std::move(sampler))
  53. .SetNumSamples(num_samples).SetDecode(decode).Build(&so);
  54. return so;
  55. }
  56. class MindDataTestVOCSampler : public UT::DatasetOpTesting {
  57. protected:
  58. };