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

Function run_poisson

dnn/test/naive/rng.cpp:85–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84template <typename dtype>
85void 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
110template <typename T>
111void run_multinomial(Handle* handle) {

Callers

nothing calls this directly

Calls 5

get_mean_varFunction · 0.85
absFunction · 0.50
ptrMethod · 0.45
execMethod · 0.45
tensorndMethod · 0.45

Tested by

no test coverage detected