MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / MatrixMul>

Method MatrixMul>

src/plugin/impl/opr_footprint.cpp:285–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283// MatrixMul
284template <>
285uint64_t opr_footprint_func<opr::MatrixMul>(cg::OperatorNodeBase* opr) {
286 auto&& mopr = opr->cast_final_safe<opr::MatrixMul>();
287 auto &&i0 = opr->input(0)->shape(), &&i1 = opr->input(1)->shape();
288 mgb_assert(i0.ndim == 2 && i1.ndim == 2);
289 auto m = i0[0], k0 = i0[1], k1 = i1[0], n = i1[1];
290 if (mopr.param().transposeA) {
291 std::swap(m, k0);
292 }
293 if (mopr.param().transposeB) {
294 std::swap(k1, n);
295 }
296 mgb_assert(k0 == k1);
297 // mul and add are counted as 2 operations
298 return m * k0 * n * 2;
299}
300
301template <>
302uint64_t opr_footprint_func<opr::LocalShareForward>(cg::OperatorNodeBase* opr) {

Callers

nothing calls this directly

Calls 4

swapFunction · 0.85
shapeMethod · 0.45
inputMethod · 0.45
paramMethod · 0.45

Tested by

no test coverage detected