| 29 | } |
| 30 | |
| 31 | static bool checkMatMul(const float* C, const float* A, const float* B, int e, int l, int h) { |
| 32 | bool res = true; |
| 33 | for (int y = 0; y < h; ++y) { |
| 34 | auto AY = A + l * y; |
| 35 | auto CY = C + e * y; |
| 36 | for (int x = 0; x < e; ++x) { |
| 37 | auto BX = B + x; |
| 38 | float expected = 0.0f; |
| 39 | auto computed = CY[x]; |
| 40 | for (int k = 0; k < l; ++k) { |
| 41 | expected += AY[k] * BX[k * e]; |
| 42 | } |
| 43 | auto diff = fabsf(expected - computed); |
| 44 | if (diff > 0.003f * fabsf(expected)) { |
| 45 | MNN_PRINT("%f -> %f\n", expected, computed); |
| 46 | res = false; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | return res; |
| 51 | } |
| 52 | |
| 53 | static void _originMatMul(float* C, const float* A, const float* B, int e, int l, int h) { |
| 54 | for (int y = 0; y < e; ++y) { |