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

Function gen_svd_input

src/opr/test/blas.cpp:764–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762namespace {
763
764void gen_svd_input(HostTensorND& dest) {
765 auto ptr = dest.ptr<float>();
766 auto dim = dest.layout().ndim;
767 size_t n = dest.layout().shape[dim - 2], m = dest.layout().shape[dim - 1];
768 size_t j = 0, k = 0;
769 float batch_off = 0;
770 float max_val = std::min(m, n) * std::min(m, n) + 0.99;
771 for (size_t i = 0, it = dest.layout().total_nr_elems(); i < it; ++i) {
772 if (i % (n * m) == 0) {
773 batch_off += 0.32;
774 j = k = 0;
775 }
776 if (!((i % (n * m)) % (m + 1)))
777 ptr[i] = (j++) + ((++k / 10.0));
778 else
779 ptr[i] = (j++);
780 ptr[i] += batch_off;
781 ptr[i] = std::fmod(ptr[i], max_val);
782 }
783}
784
785template <int have_u, int have_s, int have_v>
786void run_svd_empty_grad_test() {

Callers

nothing calls this directly

Calls 4

minFunction · 0.50
fmodFunction · 0.50
layoutMethod · 0.45
total_nr_elemsMethod · 0.45

Tested by

no test coverage detected