MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / checkMat

Function checkMat

tests/unittests/fp8_gemm_test/worker.cpp:18–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17template<typename TA, typename TB>
18void checkMat(TA* A, TB* B, int size, std::string mark)
19{
20 float max_diff = -10000.0f;
21 float max_diff_a, max_diff_b;
22 TA* matA = (TA*)malloc(sizeof(TA) * size);
23 TB* matB = B;
24 int not_passed = 0;
25 cudaMemcpy(matA, A, sizeof(TA) * size, cudaMemcpyDeviceToHost);
26 // cudaMemcpy(matB, B, sizeof(TB) * size, cudaMemcpyDeviceToHost);
27 printf("[INFO] A B abs_diff rel_diff\n");
28 for (int jjj = 0; jjj < size; jjj++) {
29 float diff = fabs(float(matA[jjj]) - float(matB[jjj]));
30 if (diff > max_diff) {
31 max_diff = diff;
32 max_diff_a = float(matA[jjj]);
33 max_diff_b = float(matB[jjj]);
34 }
35 // if (fabs(float(matA[jjj]) - float(matB[jjj])) > 0.001) {
36 not_passed += 1;
37 if (not_passed < 100)
38 printf("%4d %10.4f %10.4f %10.4f (%7.4f %% percent)\n",
39 jjj,
40 float(matA[jjj]),
41 float(matB[jjj]),
42 diff,
43 (diff) / (float(matA[jjj] + 1e-6f)) * 100.f);
44 // }
45 }
46 printf("[%s] max diff : %f ; a : %f ; b : %f\n", mark.c_str(), max_diff, max_diff_a, max_diff_b);
47 if (not_passed != 0)
48 printf("[%s] different elements : %d \n", mark.c_str(), not_passed);
49 else
50 printf("[%s] check pass!\n", mark.c_str());
51 free(matA);
52 // free(matB);
53}
54
55void getAMax(float* amax_ptr, float* input, const int m, const int n)
56{

Callers 1

cublasTesterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected