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

Function argsort_data_gen

src/opr/test/misc.cpp:26–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26void argsort_data_gen(HostTensorND& dest) {
27 mgb_assert(dest.layout().ndim == 2 && dest.layout().is_contiguous());
28 size_t m = dest.layout()[0], n = dest.layout()[1];
29 auto ptr = dest.ptr<float>();
30 RNGxorshf rng{next_rand_seed()};
31 std::uniform_real_distribution<float> dist_base{-10.f, 10.f},
32 dist_delta{0.1f, 1.2f};
33 for (size_t i = 0; i < m; ++i) {
34 auto v = dist_base(rng);
35 for (size_t j = 0; j < n; ++j) {
36 ptr[j] = v;
37 v += dist_delta(rng);
38 }
39 std::shuffle(ptr, ptr + n, rng);
40 ptr += n;
41 }
42}
43} // namespace
44
45TEST(TestOprMisc, Argmxx) {

Callers

nothing calls this directly

Calls 2

layoutMethod · 0.45
is_contiguousMethod · 0.45

Tested by

no test coverage detected