update sample bf16TensorCoreGemm to add explicit casting

This commit is contained in:
Rutwik Choughule 2021-11-01 13:22:44 +05:30
parent 1f76a2d110
commit 01789304f0

View File

@ -184,13 +184,13 @@ __host__ void init_host_matrices(__nv_bfloat16 *a, __nv_bfloat16 *b, float *c)
{ {
for (int i = 0; i < M_GLOBAL; i++) { for (int i = 0; i < M_GLOBAL; i++) {
for (int j = 0; j < K_GLOBAL; j++) { for (int j = 0; j < K_GLOBAL; j++) {
a[i*K_GLOBAL+j] = (__nv_bfloat16)(rand() % 3); a[i*K_GLOBAL+j] = (__nv_bfloat16)(float)(rand() % 3);
} }
} }
for (int i = 0; i < N_GLOBAL; i++) { for (int i = 0; i < N_GLOBAL; i++) {
for (int j = 0; j < K_GLOBAL; j++) { for (int j = 0; j < K_GLOBAL; j++) {
b[i*K_GLOBAL+j] = (__nv_bfloat16)(rand() % 3); b[i*K_GLOBAL+j] = (__nv_bfloat16)(float)(rand() % 3);
} }
} }