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

Function printDevBuffer

tests/unittests/fp8_gemm_test/worker.cpp:123–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121
122template<typename T>
123void printDevBuffer(void* devPtr, const size_t sizeBytes, const size_t row)
124{
125 std::vector<T> hBuffer(sizeBytes / sizeof(T), static_cast<T>(0.0));
126 const auto status = cudaMemcpy(hBuffer.data(), devPtr, hBuffer.size() * sizeof(T), cudaMemcpyDeviceToHost);
127 if (status != cudaSuccess) {
128 std::cout << "Failed to copy dev buffer's content!" << std::endl;
129 return;
130 }
131 printf("hBuffer.size(): %d \n", (int)hBuffer.size());
132 for (size_t i = 0; i < hBuffer.size(); i++) {
133 if (!(i % row)) {
134 std::cout << std::endl;
135 }
136 std::cout << (float)hBuffer[i] << " ";
137 }
138 std::cout << std::endl << std::endl;
139}
140
141//------------------------------------------------
142

Callers

nothing calls this directly

Calls 2

dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected