| 661 | |
| 662 | template<class precision=float> |
| 663 | void checkCPU(size_t M, size_t K, size_t N, std::unique_ptr<precision[]> &inputPtr, |
| 664 | std::unique_ptr<precision[]> &weightsPtr, |
| 665 | std::unique_ptr<precision[]> &outputPtr) { |
| 666 | LOG(kDefLog, kInfo, "Computing CPU reference implementation"); |
| 667 | std::unique_ptr<precision[]> outputRefPtr = std::make_unique<precision[]>(M * N); |
| 668 | if constexpr (std::is_same<precision, float>::value) { |
| 669 | ref::matmul_forward_cpu(outputRefPtr.get(), inputPtr.get(), weightsPtr.get(), |
| 670 | nullptr, 1, M, K, N); |
| 671 | } else if constexpr (std::is_same<precision, half>::value) { |
| 672 | matmulf16_forward_cpu(outputRefPtr.get(), inputPtr.get(), weightsPtr.get(), |
| 673 | nullptr, 1, M, K, N); |
| 674 | } |
| 675 | LOG(kDefLog, kInfo, "Reference Output: %s", |
| 676 | show<precision>(outputRefPtr.get(), M, N, "Output (Reference)").c_str()); |
| 677 | LOG(kDefLog, kInfo, |
| 678 | isclose(outputPtr.get(), outputRefPtr.get(), M * N) ? "CPU Check: PASS" |
| 679 | : "CPU Check: FAIL"); |
| 680 | } |
| 681 | |
| 682 | Kernel selectMatmul(Context &ctx, int version, |
| 683 | const Bindings</* input, weights, output */ 3> &bindings, |
no test coverage detected