MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / checkCPU

Function checkCPU

examples/matmul/run.cpp:663–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661
662template<class precision=float>
663void 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
682Kernel selectMatmul(Context &ctx, int version,
683 const Bindings</* input, weights, output */ 3> &bindings,

Callers 1

runTestWithCheckFunction · 0.85

Calls 3

LOGFunction · 0.85
matmulf16_forward_cpuFunction · 0.85
iscloseFunction · 0.85

Tested by

no test coverage detected