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

Function TEST

dnn/test/common/rng.cpp:389–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389TEST(RNG, NO_REPLACEMENT_RNG) {
390 static const size_t N = 10, TIMES = 100;
391 UniformIntRNG base_rng(0, N - 1);
392 NoReplacementRNG rng(&base_rng);
393 auto handle = create_cpu_handle(2, false);
394 for (size_t t = 0; t < TIMES; ++t) {
395 TensorLayout layout({N}, dtype::Float32());
396 Tensor<> tensor(handle.get(), layout);
397 rng.gen(tensor.tensornd());
398 std::vector<float> vals;
399 for (size_t i = 0; i < N; ++i)
400 vals.push_back(tensor.ptr()[i]);
401 std::sort(vals.begin(), vals.end());
402 for (size_t i = 0; i < N; ++i)
403 ASSERT_EQ(static_cast<float>(i), vals[i]);
404 }
405}
406// vim: syntax=cpp.doxygen

Callers

nothing calls this directly

Calls 8

sortFunction · 0.85
getMethod · 0.45
genMethod · 0.45
tensorndMethod · 0.45
push_backMethod · 0.45
ptrMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected