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 928 B

12345678910111213141516171819202122232425262728
  1. #include "test/common/indexing_one_hot.h"
  2. #include "test/common/checker.h"
  3. #include "megdnn/oprs/general.h"
  4. using namespace megdnn;
  5. using namespace test;
  6. void test::run_indexing_one_hot_test(
  7. Handle* handle, const thin_function<void()>& fail_test) {
  8. Checker<IndexingOneHot> checker(handle);
  9. UniformIntRNG rng_idx{0, 7};
  10. checker.set_param({2}).set_dtype(1, dtype::Int32{}).set_rng(1, &rng_idx);
  11. checker.execs({{10, 4, 8, 9}, {10, 4, 9}, {}});
  12. if (fail_test) {
  13. rng_idx = {100, 200};
  14. checker.set_expect_exec_fail(fail_test).execs({{10, 4, 8, 9}, {10, 4, 9}, {}});
  15. }
  16. }
  17. void test::run_indexing_set_one_hot_test(Handle* handle) {
  18. Checker<IndexingSetOneHot> 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}, {10, 4, 1, 9}});
  22. }
  23. // vim: syntax=cpp.doxygen