| 236 | |
| 237 | template <typename dtype> |
| 238 | void run_beta(Handle* handle) { |
| 239 | using ctype = typename DTypeTrait<dtype>::ctype; |
| 240 | auto opr = handle->create_operator<BetaRNG>(); |
| 241 | |
| 242 | TensorLayout ly{TensorShape{200000 * 5}, dtype()}; |
| 243 | |
| 244 | Tensor<ctype> out(handle, ly); |
| 245 | Tensor<ctype> alpha(handle, ly); |
| 246 | Tensor<ctype> beta(handle, ly); |
| 247 | |
| 248 | auto alpha_ptr = alpha.ptr(); |
| 249 | auto beta_ptr = beta.ptr(); |
| 250 | for (int i = 0; i < 5; ++i) { |
| 251 | for (int j = 0; j < 200000; ++j) { |
| 252 | alpha_ptr[i * 200000 + j] = 0.3 * i + 0.1; |
| 253 | beta_ptr[i * 200000 + j] = 2 * i * 0.3 + 0.1; |
| 254 | } |
| 255 | } |
| 256 | opr->exec(alpha.tensornd(), beta.tensornd(), out.tensornd(), {}); |
| 257 | |
| 258 | auto ptr = out.ptr(); |
| 259 | for (int i = 0; i < 5; ++i) { |
| 260 | float a = 0.3 * i + 0.1, b = 2 * i * 0.3 + 0.1; |
| 261 | float mean = a / (a + b); |
| 262 | float std = a * b / ((a + b) * (a + b) * (a + b + 1)); |
| 263 | auto stat = get_mean_var(ptr + i * 200000, 200000, ctype(mean)); |
| 264 | ASSERT_LE(std::abs(stat.first - mean), 0.01); |
| 265 | ASSERT_LE(std::abs(stat.second - std), 0.01); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | template <typename dtype> |
| 270 | void run_permutation(Handle* handle) { |
nothing calls this directly
no test coverage detected