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.

sliding_window_transpose.cpp 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * \file dnn/test/naive/sliding_window_transpose.cpp
  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. #include "test/naive/fixture.h"
  12. #include "megdnn/oprs/nn.h"
  13. #include "test/common/checker.h"
  14. using namespace megdnn;
  15. using namespace test;
  16. TEST_F(NAIVE, SlidingWindowTranspose_FORWARD) {
  17. Checker<SlidingWindowTranspose> checker(handle(), /* check_dispatch */ false);
  18. SlidingWindowTranspose::Param param(3, 3, 0, 0, 1, 1, 1, 1, 2, 2);
  19. checker.set_param(param).exect(
  20. Testcase{
  21. TensorValue(
  22. {1, 1, 2, 2, 2, 2}, dtype::Uint8(),
  23. {0, 1, 3, 4, 1, 2, 4, 5, 3, 4, 6, 7, 4, 5, 7, 8}),
  24. {}},
  25. Testcase{
  26. {},
  27. TensorValue(
  28. {1, 1, 3, 3}, dtype::Uint8(),
  29. {0, 2, 2, 6, 16, 10, 6, 14, 8})});
  30. param.out_h = 6;
  31. param.out_w = 7;
  32. param.pad_h = 1;
  33. param.pad_w = 1;
  34. param.stride_h = 2;
  35. param.stride_w = 2;
  36. param.dilate_h = 2;
  37. param.dilate_w = 2;
  38. param.window_h = 3;
  39. param.window_w = 3;
  40. checker.set_param(param).exect(
  41. Testcase{
  42. TensorValue(
  43. {1, 1, 2, 3, 3, 3}, dtype::Uint8(),
  44. {0, 0, 0, 0, 8, 10, 0, 22, 24, 0, 0, 0, 8, 10,
  45. 12, 22, 24, 26, 0, 0, 0, 10, 12, 0, 24, 26, 0, 0,
  46. 8, 10, 0, 22, 24, 0, 36, 38, 8, 10, 12, 22, 24, 26,
  47. 36, 38, 40, 10, 12, 0, 24, 26, 0, 38, 40, 0}),
  48. {}},
  49. Testcase{
  50. {},
  51. TensorValue(
  52. {1, 1, 6, 7}, dtype::Uint8(),
  53. {0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 60, 0, 48, 0,
  54. 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, 144, 0, 104, 0,
  55. 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 114, 0, 80, 0})});
  56. }