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.

tile_repeat.h 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * \file dnn/test/common/tile_repeat.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #pragma once
  12. #include "megdnn/oprs.h"
  13. namespace megdnn {
  14. namespace test {
  15. namespace tile_repeat {
  16. struct Arg {
  17. TensorShape times, src, dst;
  18. Arg(TensorShape times, TensorShape src) : times(times), src(src) {
  19. dst = src;
  20. for (size_t i = 0; i < src.ndim; ++i) {
  21. dst[i] *= times[i];
  22. }
  23. }
  24. TileRepeatBase::Param param() {
  25. TileRepeatBase::Param param;
  26. param.times = times;
  27. return param;
  28. }
  29. };
  30. inline std::vector<Arg> get_args() {
  31. std::vector<Arg> args;
  32. args.emplace_back(TensorShape{3}, TensorShape{10000});
  33. args.emplace_back(TensorShape{1, 1}, TensorShape{200, 300});
  34. args.emplace_back(TensorShape{1, 3}, TensorShape{200, 300});
  35. args.emplace_back(TensorShape{2, 1}, TensorShape{200, 300});
  36. args.emplace_back(TensorShape{2, 3}, TensorShape{200, 300});
  37. for (unsigned mask = 0; mask < 32; ++mask) {
  38. auto b = [mask](unsigned bit) { return (mask >> bit) & 1; };
  39. args.emplace_back(
  40. TensorShape{b(0) + 1, b(1) + 1, b(2) + 1, b(3) + 1, b(4) + 1},
  41. TensorShape{3, 4, 5, 6, 7});
  42. }
  43. for (size_t i = 1; i < 10; ++i)
  44. for (size_t j = 1; j < 10; ++j) {
  45. args.emplace_back(TensorShape{i, j}, TensorShape{3, 4});
  46. }
  47. return args;
  48. }
  49. } // namespace tile_repeat
  50. } // namespace test
  51. } // namespace megdnn
  52. // vim: syntax=cpp.doxygen