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

Function run_batched_sgemm_test

src/opr/test/blas.cpp:112–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112void run_batched_sgemm_test(bool transa, bool transb) {
113 using Checker = AutoOprChecker<2, 1>;
114 auto make_graph = [&](const Checker::SymInpArray& inputs) -> Checker::SymOutArray {
115 return {opr::BatchedMatrixMul::make(inputs[0], inputs[1], {transa, transb})};
116 };
117
118 auto fwd = FWD_BATCH_GEMM(float, float);
119
120 auto mkshp = [](bool trans, size_t b, size_t m, size_t k) {
121 TensorShape rst{b, m, k};
122 if (trans)
123 std::swap(rst.shape[1], rst.shape[2]);
124 return rst;
125 };
126 using namespace std::placeholders;
127 auto mkx = std::bind(mkshp, transa, _1, _2, _3);
128 auto mky = std::bind(mkshp, transb, _1, _2, _3);
129
130 Checker::RunOptions opt;
131 opt.numdiff_eps = 1;
132 Checker(make_graph, fwd)
133 .run({mkx(3, 5, 7), mky(3, 7, 2)}, opt)
134 .run({mkx(64, 1, 2), mky(64, 2, 1)}, opt)
135 .run({mkx(1, 2, 3), mky(1, 3, 4)}, opt)
136 .run({mkx(3, 0, 2), mky(3, 2, 0)}, opt)
137 .run({mkx(64, 10, 0), mky(64, 0, 10)}, opt);
138}
139
140auto gen_fp16 = [](HostTensorND& dest) {
141 RNGxorshf rng{next_rand_seed()};

Callers 1

TESTFunction · 0.85

Calls 4

swapFunction · 0.85
makeFunction · 0.70
CheckerClass · 0.50
runMethod · 0.45

Tested by

no test coverage detected