| 142 | } // namespace |
| 143 | |
| 144 | TEST_F(NAIVE, MATRIX_MUL_QUANTIZED4x4x32) { |
| 145 | Checker<MatrixMul> checker(handle(), /* check_dispatch */ false); |
| 146 | auto GenTensorValueQuint4 = [](const TensorShape& shape, |
| 147 | dtype::Quantized4Asymm dtype, |
| 148 | const std::vector<int>& values) { |
| 149 | TensorND tensor; |
| 150 | tensor.layout = {shape, dtype}; |
| 151 | tensor.reset_ptr( |
| 152 | static_cast<dt_byte*>(malloc(tensor.layout.span().dist_byte()))); |
| 153 | uint8_t* ptr = static_cast<uint8_t*>(tensor.raw_ptr()); |
| 154 | megdnn_assert(values.size() == tensor.layout.span().dist_elem()); |
| 155 | for (size_t i = 0; i < tensor.layout.span().dist_elem(); i += 2) { |
| 156 | int val0 = values[i], val1 = values[i + 1]; |
| 157 | ptr[i / 2] = val0 | (val1 << 4); |
| 158 | } |
| 159 | return tensor; |
| 160 | }; |
| 161 | using Param = MatrixMul::Param; |
| 162 | Param param; |
| 163 | checker.set_param(param); |
| 164 | checker.set_dtype(2, dtype::QuantizedS32(0.3f * 0.3f)); |
| 165 | checker.exect( |
| 166 | Testcase{ |
| 167 | GenTensorValueQuint4( |
| 168 | {8, 8}, dtype::Quantized4Asymm(0.3f, (uint8_t)8), |
| 169 | {13, 2, 4, 13, 9, 3, 14, 14, 14, 5, 3, 3, 15, |
| 170 | 11, 8, 8, 5, 7, 14, 15, 8, 2, 11, 1, 15, 9, |
| 171 | 13, 14, 2, 3, 11, 11, 15, 10, 11, 0, 13, 12, 3, |
| 172 | 11, 9, 9, 10, 5, 2, 5, 8, 4, 6, 9, 0, 0, |
| 173 | 3, 9, 9, 8, 8, 15, 7, 5, 0, 3, 9, 10}), |
| 174 | GenTensorValueQuint4( |
| 175 | {8, 8}, dtype::Quantized4Asymm(0.3f, (uint8_t)8), |
| 176 | {5, 14, 13, 11, 4, 7, 12, 12, 11, 7, 13, 10, 5, |
| 177 | 6, 4, 2, 3, 12, 2, 2, 13, 3, 14, 0, 15, 15, |
| 178 | 0, 2, 2, 13, 3, 14, 10, 8, 9, 11, 0, 14, 15, |
| 179 | 4, 14, 7, 1, 6, 13, 2, 12, 5, 2, 15, 7, 11, |
| 180 | 13, 9, 8, 10, 0, 11, 6, 10, 12, 2, 2, 12}), |
| 181 | {}}, |
| 182 | Testcase{ |
| 183 | {}, |
| 184 | {}, |
| 185 | TensorValue( |
| 186 | {8, 8}, dtype::QuantizedS32(0.3f * 0.3f), |
| 187 | {-90, 120, -3, 40, -31, 58, -54, 165, -5, -19, 71, |
| 188 | 87, -51, 24, 92, 15, 27, 62, -59, -82, -40, 91, |
| 189 | 11, -16, -85, 138, -18, -36, 8, -25, -56, 75, -46, |
| 190 | -34, 67, 53, -4, -83, 111, -86, -29, -17, 45, -9, |
| 191 | 38, -22, -3, -19, -17, -95, 94, 78, 63, -35, -51, |
| 192 | 21, -63, -14, 87, 31, 44, -53, -107, 5}), |
| 193 | }); |
| 194 | } |
| 195 | |
| 196 | TEST_F(NAIVE, MATRIX_MUL_QUANTIZEDS4_4x4x16) { |
| 197 | Checker<MatrixMul> checker(handle(), /* check_dispatch */ false); |
nothing calls this directly
no test coverage detected