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.

tensor_remap.cpp 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * \file dnn/test/cuda/tensor_remap.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/cuda/fixture.h"
  12. #include "test/common/checker.h"
  13. #include "test/common/tensor_remap.h"
  14. namespace megdnn {
  15. namespace test {
  16. TEST_F(CUDA, TENSOR_REMAP_FORWARD) {
  17. Checker<IndexingRemapForward> checker(handle_cuda());
  18. TensorShape src{11, 13, 17}, map{3, 5, 7, 3}, dst{3, 5, 7};
  19. checker.set_dtype(1, dtype::Int32());
  20. for (auto dt : std::vector<DType>{dtype::Float32(), dtype::Int32()}) {
  21. checker.set_dtype(0, dt);
  22. checker.set_dtype(2, dt);
  23. using namespace tensor_remap;
  24. {
  25. MapRNG rng(src);
  26. checker.set_rng(1, &rng).execs({src, map, {}});
  27. }
  28. {
  29. NonoverlappingMapRNG rng(src);
  30. checker.set_rng(1, &rng).execs({src, map, {}});
  31. }
  32. }
  33. }
  34. TEST_F(CUDA, TENSOR_REMAP_BACKWARD) {
  35. Checker<IndexingRemapBackward> checker(handle_cuda());
  36. checker.set_dtype(1, dtype::Int32());
  37. TensorShape src{11, 13, 17}, map{3, 5, 7, 3}, dst{3, 5, 7};
  38. checker.set_dtype(1, dtype::Int32());
  39. for (auto dt : std::vector<DType>{dtype::Float32(), dtype::Int32()}) {
  40. checker.set_dtype(0, dt);
  41. checker.set_dtype(2, dt);
  42. using namespace tensor_remap;
  43. {
  44. MapRNG rng(src);
  45. checker.set_rng(1, &rng).execs({dst, map, src});
  46. }
  47. {
  48. NonoverlappingMapRNG rng(src);
  49. checker.set_rng(1, &rng).execs({dst, map, src});
  50. }
  51. }
  52. }
  53. } // namespace test
  54. } // namespace megdnn
  55. // vim: syntax=cpp.doxygen