| 43 | |
| 44 | template <typename T> |
| 45 | void run_poisson(Handle* handle) { |
| 46 | using ctype = typename DTypeTrait<T>::ctype; |
| 47 | auto opr = handle->create_operator<PoissonRNG>(); |
| 48 | |
| 49 | TensorLayout ly{TensorShape{200000 * 5}, T()}; |
| 50 | |
| 51 | SyncedTensor<ctype> out(handle, ly); |
| 52 | SyncedTensor<ctype> lam(handle, ly); |
| 53 | auto lam_ptr = lam.ptr_mutable_host(); |
| 54 | for (int i = 0; i < 5; ++i) { |
| 55 | for (int j = 0; j < 200000; ++j) { |
| 56 | lam_ptr[i * 200000 + j] = ctype(i + 1); |
| 57 | } |
| 58 | } |
| 59 | opr->exec(lam.tensornd_dev(), out.tensornd_dev(), {}); |
| 60 | |
| 61 | auto ptr = out.ptr_mutable_host(); |
| 62 | for (int i = 0; i < 5; ++i) { |
| 63 | auto stat = get_mean_var(ptr + i * 200000, 200000, ctype(i + 1)); |
| 64 | ASSERT_LE(std::abs(stat.first - ctype(i + 1)), 0.01); |
| 65 | ASSERT_LE(std::abs(stat.second - ctype(i + 1)), 0.01); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | template <typename T> |
| 70 | void run_multinomial(Handle* handle) { |
nothing calls this directly
no test coverage detected