MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / run_poisson

Function run_poisson

dnn/test/cuda/rng.cpp:45–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template <typename T>
45void 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
69template <typename T>
70void run_multinomial(Handle* handle) {

Callers

nothing calls this directly

Calls 4

TClass · 0.85
get_mean_varFunction · 0.85
absFunction · 0.50
execMethod · 0.45

Tested by

no test coverage detected