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.

indexing_one_hot.cpp 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * \file dnn/test/common/indexing_one_hot.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/common/indexing_one_hot.h"
  12. #include "test/common/checker.h"
  13. #include "megdnn/oprs/general.h"
  14. using namespace megdnn;
  15. using namespace test;
  16. void test::run_indexing_one_hot_test(
  17. Handle* handle, const thin_function<void()>& fail_test) {
  18. Checker<IndexingOneHot> checker(handle);
  19. UniformIntRNG rng_idx{0, 7};
  20. checker.set_param({2}).set_dtype(1, dtype::Int32{}).set_rng(1, &rng_idx);
  21. checker.execs({{10, 4, 8, 9}, {10, 4, 9}, {}});
  22. if (fail_test) {
  23. rng_idx = {100, 200};
  24. checker.set_expect_exec_fail(fail_test).execs({{10, 4, 8, 9}, {10, 4, 9}, {}});
  25. }
  26. }
  27. void test::run_indexing_set_one_hot_test(Handle* handle) {
  28. Checker<IndexingSetOneHot> checker(handle);
  29. UniformIntRNG rng_idx{0, 7};
  30. checker.set_param({2}).set_dtype(1, dtype::Int32{}).set_rng(1, &rng_idx);
  31. checker.execs({{10, 4, 8, 9}, {10, 4, 9}, {10, 4, 1, 9}});
  32. }
  33. // vim: syntax=cpp.doxygen