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

Method make

dnn/test/common/svd.cpp:58–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56} // namespace
57
58std::vector<SVDTestcase> SVDTestcase::make() {
59 std::vector<SVDTestcase> ret;
60
61 auto param = Param(false /* compute_uv */, false /* full_matrices */);
62 auto add_shape = [&ret, &param](const TensorShape& shape) {
63 ret.push_back({param, TensorLayout{shape, dtype::Float32()}});
64 };
65
66 add_shape({1, 7, 7});
67 add_shape({1, 3, 7});
68 add_shape({1, 7, 3});
69 for (size_t rows : {2, 3, 5, 7, 10, 32, 100}) {
70 for (size_t cols : {2, 3, 5, 7, 10, 32, 100}) {
71 param.compute_uv = false;
72 param.full_matrices = false;
73 add_shape({3, rows, cols});
74
75 param.compute_uv = true;
76 add_shape({2, rows, cols});
77 param.full_matrices = true;
78 add_shape({3, rows, cols});
79 }
80 }
81
82 NormalRNG data_rng;
83 auto fill_data = [&](TensorND& data) {
84 auto sz = data.layout.span().dist_byte(), szf = sz / sizeof(dt_float32);
85 auto pf = static_cast<dt_float32*>(data.raw_ptr());
86 data_rng.fill_fast_float32(pf, szf);
87 };
88
89 for (auto&& i : ret) {
90 i.m_mem.reset(new dt_float32[i.m_mat.layout.span().dist_elem()]);
91 i.m_mat.reset_ptr(i.m_mem.get());
92 fill_data(i.m_mat);
93 }
94
95 return ret;
96}
97
98SVDTestcase::Result SVDTestcase::run(SVDForward* opr) {
99 auto handle = opr->handle();

Callers

nothing calls this directly

Calls 10

dist_byteMethod · 0.80
spanMethod · 0.80
fill_fast_float32Method · 0.80
dist_elemMethod · 0.80
reset_ptrMethod · 0.80
ParamClass · 0.50
push_backMethod · 0.45
raw_ptrMethod · 0.45
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected