message: Add an environment variable to force Conv algorithm to use CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM.
diff: @@ -677,6 +677,18 @@ bool RequireCudnnDeterminism() {
  return require_cudnn_determinism;
  }
  +// A helper function to decide whether to force the default conv algorithm.
  +bool ConvUseDefaultAlgorithm() {
  + static bool use_default = [] {
  + bool use_default = false;
  + TF_CHECK_OK(tensorflow::ReadBoolFromEnvVar("TF_USE_DEFAULT_CONV_ALGO",
  + /*default_val=*/false,
  + &use_default));
  + return use_default;
  + }();
  + return use_default;
  +}
  +
  std::tuple<int, int> GetCcMajorMinor(Stream* stream) {
  int cc_major, cc_minor;
  stream->parent()->GetDeviceDescription().cuda_compute_capability(&cc_major,
  @@ -3337,7 +3349,12 @@ bool CudnnSupport::GetConvolveAlgorithms(
  bool tensor_op_math_available = TensorOpMathAvailable(cc_major);
  out_algorithms->clear();
  - std::vector<dnn::AlgorithmDesc::Index> algo_types = {
  + std::vector<dnn::AlgorithmDesc::Index> algo_types;
  + if (ConvUseDefaultAlgorithm()) {
  + // Force a fallback algorithm.
  + algo_types = {CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM};
  + } else {
  + algo_types = {
  // clang-format off
  CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM,
  CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM,
  @@ -3353,6 +3370,7 @@ bool CudnnSupport::GetConvolveAlgorithms(
  if (CudnnEnvVar<WinogradNonfused>::IsEnabled() && with_winograd_nonfused) {
  algo_types.push_back(CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED);
  }
  + }
  // The algorithms are intentionally ordered for deterministic operation
  for (auto i : algo_types) {
  