| 30 | |
| 31 | template <typename dtype> |
| 32 | void run_gaussian(Handle* handle) { |
| 33 | using ctype = typename DTypeTrait<dtype>::ctype; |
| 34 | auto opr = handle->create_operator<GaussianRNG>(); |
| 35 | opr->param().mean = 0.8; |
| 36 | opr->param().std = 2.3; |
| 37 | opr->param().dtype = DTypeTrait<dtype>::enumv; |
| 38 | Tensor<ctype> t(handle, {TensorShape{200001}, dtype()}); |
| 39 | opr->exec(t.tensornd(), {}); |
| 40 | |
| 41 | auto ptr = t.ptr(); |
| 42 | auto size = t.layout().total_nr_elems(); |
| 43 | for (size_t i = 0; i < size; ++i) { |
| 44 | ASSERT_LE(std::abs(ptr[i] - 0.8), ctype(15)); |
| 45 | } |
| 46 | auto stat = get_mean_var(ptr, size, ctype(0.8)); |
| 47 | |
| 48 | ASSERT_LE(std::abs(stat.first - 0.8), 5e-3); |
| 49 | ASSERT_LE(std::abs(stat.second - 2.3 * 2.3), 5e-2); |
| 50 | } |
| 51 | |
| 52 | template <typename dtype> |
| 53 | void run_gamma(Handle* handle) { |
nothing calls this directly
no test coverage detected