eric-haibin-lin commented on a change in pull request #17466: Bert gemms true
fp16
URL: https://github.com/apache/incubator-mxnet/pull/17466#discussion_r372206029
##########
File path: src/operator/linalg_impl.h
##########
@@ -261,25 +262,43 @@ void linalg_gemm<gpu, mshadow::half::half_t>(const
Tensor<gpu, 2, mshadow::half:
auto previous_math_mode = SetCublasMathMode(blas_handle, cublas_math_mode);
#endif
- // pseudo-fp16 (fp32 math with fp16 I/O)
- float alpha_f = float(alpha); // NOLINT(*)
- float beta_f = float(beta); // NOLINT(*)
-
- // As of cuda8, cublas adopted the cuda datatype, rather than maintaining
its own datatype.
+// As of cuda8, cublas adopted the cuda datatype, rather than maintaining its
own datatype.
#if CUDA_VERSION >= 8000
cudaDataType_t half_datatype = CUDA_R_16F;
#else
cublasDataType_t half_datatype = CUBLAS_DATA_HALF;
#endif
- CUBLAS_CALL(cublasSgemmEx(blas_handle,
- (tB ? CUBLAS_OP_T : CUBLAS_OP_N),
- (tA ? CUBLAS_OP_T : CUBLAS_OP_N),
- C.size(1), C.size(0), (tB ? B.size(1) : B.size(0)),
- &alpha_f,
- B.dptr_, half_datatype, B.stride_,
- A.dptr_, half_datatype, A.stride_,
- &beta_f,
- C.dptr_, half_datatype, C.stride_));
+ auto algo = CUBLAS_GEMM_DEFAULT_TENSOR_OP;
+ using TrueFP16Type = mshadow::half::half_t;
+ using PseudoFP16Type = typename CublasType<mshadow::half::half_t>::ScaleType;
+ TrueFP16Type trueFP16_alpha = static_cast<TrueFP16Type>(alpha);
+ TrueFP16Type trueFP16_beta = static_cast<TrueFP16Type>(beta);
+ PseudoFP16Type pseudoFP16_alpha = static_cast<PseudoFP16Type>(alpha);
+ PseudoFP16Type pseudoFP16_beta = static_cast<PseudoFP16Type>(beta);
+ const void *alpha_ptr;
+ const void *beta_ptr;
+ cudaDataType_t computeType;
+ bool use_true_fp16 = dmlc::GetEnv("MXNET_FC_TRUE_FP16", false);
Review comment:
For new env vars, please document in
https://github.com/apache/incubator-mxnet/blob/master/docs/static_site/src/pages/api/faq/env_var.md
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services