| 83 | |
| 84 | template <typename dtype> |
| 85 | void run_poisson(Handle* handle) { |
| 86 | using ctype = typename DTypeTrait<dtype>::ctype; |
| 87 | auto opr = handle->create_operator<PoissonRNG>(); |
| 88 | |
| 89 | TensorLayout ly{TensorShape{200000 * 5}, dtype()}; |
| 90 | |
| 91 | Tensor<ctype> out(handle, ly); |
| 92 | Tensor<ctype> lam(handle, ly); |
| 93 | |
| 94 | auto lam_ptr = lam.ptr(); |
| 95 | for (int i = 0; i < 5; ++i) { |
| 96 | for (int j = 0; j < 200000; ++j) { |
| 97 | lam_ptr[i * 200000 + j] = ctype(i + 1); |
| 98 | } |
| 99 | } |
| 100 | opr->exec(lam.tensornd(), out.tensornd(), {}); |
| 101 | |
| 102 | auto ptr = out.ptr(); |
| 103 | for (int i = 0; i < 5; ++i) { |
| 104 | auto stat = get_mean_var(ptr + i * 200000, 200000, ctype(i + 1)); |
| 105 | ASSERT_LE(std::abs(stat.first - ctype(i + 1)), 0.01); |
| 106 | ASSERT_LE(std::abs(stat.second - ctype(i + 1)), 0.01); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | template <typename T> |
| 111 | void run_multinomial(Handle* handle) { |
nothing calls this directly
no test coverage detected