Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Tensor Core MathType in conv using cudnn #34409

Merged
merged 15 commits into from
Aug 4, 2021

Conversation

AshburnLee
Copy link
Contributor

@AshburnLee AshburnLee commented Jul 27, 2021

PR types

New features

PR changes

OPs

Describe

功能

当数据类型为bfloat16时,使用Tesnor Core。包括以下3部分:

  • 在创建ConvolutionDescriptor时,需要指明cudnnSetConvolutionMathType。该PR添加当dtype 为 CUDNN_DATA_BFLOAT16时,设置MathType为CUDNN_TENSOR_OP_MATH
    • 当满足PSEUDO_BFLOAT16_CONFIG时,上述设置MathType的条件应改为if (dtype == CUDNN_DATA_FLOAT && allow_tf32) 。由于满足PSEUDO_BFLOAT16_CONFIG与否,对性能无影响,故该PR设置MathType的条件是if (dtype == CUDNN_DATA_BFLOAT16)
  • 搜索反向data卷积计算的算法,当dtype为CUDNN_DATA_BFLOAT16时设置MathType为CUDNN_TENSOR_OP_MATH
  • 搜索反向filter卷积计算的算法,当dtype为CUDNN_DATA_BFLOAT16时设置MathType为CUDNN_TENSOR_OP_MATH

对于前向卷积算法的选择、后向data卷积算法选择、后向filter卷积算法选择中的设置convMathType。将三部分封装成了统一的函数。

效果

通过LOG日志发现,当数据类型为bfloat16时,代码执行期望分支。

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

#if CUDA_VERSION >= 11000
#if CUDNN_VERSION_MIN(8, 1, 0)
} else if (dev_ctx.GetComputeCapability() >= 80 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前向、反向input、反向filter,设置cudnn conv算法的代码逻辑都是一样的,可以封装成一个函数。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done,已封装成一个函数。

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

VLOG(5) << "NOT use cudnn_tensor_op_math";
}
#endif
return;
Copy link
Contributor

@Xreki Xreki Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个return是多余的,后续PR中删一下。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@Xreki Xreki merged commit c79fa1c into PaddlePaddle:develop Aug 4, 2021
@AshburnLee AshburnLee deleted the backward_TensorCore branch August 4, 2021 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants