Fix the bug of mismatching datatype in print_to_screen (#866)

Co-authored-by: liumg <mengge.liu@mobvoi.com>
This commit is contained in:
menggeliu1205 2021-03-11 07:02:07 +08:00 committed by GitHub
parent 8e131dd43b
commit 596d11a72c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -431,8 +431,8 @@ void print_to_file(T *result, const int size, char *file)
template <typename T>
void print_to_screen(T *result, const int size)
{
float *tmp = (float *)malloc(sizeof(float) * size);
check_cuda_error(cudaMemcpy(tmp, result, sizeof(float) * size, cudaMemcpyDeviceToHost));
T *tmp = (T *)malloc(sizeof(T) * size);
check_cuda_error(cudaMemcpy(tmp, result, sizeof(T) * size, cudaMemcpyDeviceToHost));
for (int i = 0; i < size; ++i)
printf("%d, %f\n", i, (float)tmp[i]);
free(tmp);