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

Function checkNonZero

examples/cpp/decoding/layernorm_test.cc:27–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template<typename T>
27int checkNonZero(T* A, int size)
28{
29 T* h_A = (T*)malloc(sizeof(T) * size);
30 cudaMemcpy(h_A, A, sizeof(T) * size, cudaMemcpyDeviceToHost);
31 int noneZeroNum = 0;
32 for (int ii = 0; ii < size; ii++) {
33 if (fabs(float(h_A[ii]) - 0.0f) > 0.0001f) {
34 noneZeroNum += 1;
35 }
36 }
37 free(h_A);
38 return noneZeroNum;
39}
40
41template<typename TA, typename TB>
42void checkMat(TA* A, TB* B, int size, const char* mark, float threshold)

Callers 1

checkMatFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected