| 10 | namespace test { |
| 11 | |
| 12 | TEST_F(ROCM, MATRIX_MUL) { |
| 13 | Checker<MatrixMul> checker(handle_rocm()); |
| 14 | using Param = MatrixMul::Param; |
| 15 | size_t m = 12, n = 16, k = 20; |
| 16 | //! result error for Int8x8x32, not test correctness |
| 17 | std::vector<DType> dtypes{DNN_INC_FLOAT16(dtype::Float16() MEGDNN_COMMA) |
| 18 | dtype::Float32() /*, dtype::Int32()*/}; |
| 19 | for (auto dtype : dtypes) { |
| 20 | for (unsigned mask = 0; mask < 4; ++mask) { |
| 21 | Param param; |
| 22 | param.transposeA = mask & 1; |
| 23 | param.transposeB = mask & 2; |
| 24 | DType stype = dtype == dtype::Int32() ? dtype::Int8() : dtype; |
| 25 | TensorShape A, B; |
| 26 | if (param.transposeA) |
| 27 | A = TensorShape{k, m}; |
| 28 | else |
| 29 | A = TensorShape{m, k}; |
| 30 | if (param.transposeB) |
| 31 | B = TensorShape{n, k}; |
| 32 | else |
| 33 | B = TensorShape{k, n}; |
| 34 | checker.set_param(param) |
| 35 | .set_dtype(0, stype) |
| 36 | .set_dtype(1, stype) |
| 37 | .set_dtype(2, dtype) |
| 38 | .set_epsilon( |
| 39 | DNN_FLOAT16_SELECT(dtype == dtype::Float16(), false) ? 5e-2 |
| 40 | : 5e-3) |
| 41 | .execs({A, B, {}}); |
| 42 | } |
| 43 | } |
| 44 | // general tests |
| 45 | auto args = matrix_mul::get_matmul_args(); |
| 46 | for (auto arg : args) { |
| 47 | auto m = arg.m, n = arg.n, k = arg.k; |
| 48 | auto mask = arg.mask; |
| 49 | Param param; |
| 50 | param.transposeA = mask & 1; |
| 51 | param.transposeB = mask & 2; |
| 52 | TensorShape AS, BS, CS; |
| 53 | if (param.transposeA) |
| 54 | AS = TensorShape{k, m}; |
| 55 | else |
| 56 | AS = TensorShape{m, k}; |
| 57 | if (param.transposeB) |
| 58 | BS = TensorShape{n, k}; |
| 59 | else |
| 60 | BS = TensorShape{k, n}; |
| 61 | CS = TensorShape{m, n}; |
| 62 | TensorLayout AL, BL, CL; |
| 63 | if (arg.A_stride == 0) { |
| 64 | AL = TensorLayout(AS, dtype::Float32()); |
| 65 | } else { |
| 66 | AL = TensorLayout(AS, {ptrdiff_t(arg.A_stride), 1}, dtype::Float32()); |
| 67 | } |
| 68 | if (arg.B_stride == 0) { |
| 69 | BL = TensorLayout(BS, dtype::Float32()); |
nothing calls this directly
no test coverage detected