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

Add float16 support to batch norm operator #9176

Merged
merged 9 commits into from
Mar 21, 2018

Conversation

kexinzhao
Copy link
Contributor

@kexinzhao kexinzhao commented Mar 19, 2018

fix #9175

Only added and verified float16 kernel for the inference mode of cudnn batch norm kernel,
which is needed to run vgg/resnet inference.

OpTest.np_dtype_to_fluid_dtype is to change the dtype of a numpy array from float16 to uint16 so that it can correctly bind with paddle float16 in tensor_py.h.

@kexinzhao kexinzhao added the 预测 原名Inference,包含Capi预测问题等 label Mar 19, 2018
@@ -118,15 +122,16 @@ class BatchNormKernel<platform::CUDADeviceContext, T>

// alloc memory
y->mutable_data<T>(ctx.GetPlace());
Copy link
Member

Choose a reason for hiding this comment

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

why here does not use BatchNormParamType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per the cudnn API, when we are using fp16 mode to run Batch norm cudnn, the data type of input x and output y will be fp16, but the other input parameters including mean and variance will still be float32 type.

So here T == float16, and BatchNormParamType<T> == float as defined in cudnn_helper.h

Copy link
Member

@jacquesqiao jacquesqiao left a comment

Choose a reason for hiding this comment

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

LGTM!

@kexinzhao kexinzhao merged commit ed2bc19 into PaddlePaddle:develop Mar 21, 2018
@kexinzhao kexinzhao deleted the batch_norm_fp16 branch March 21, 2018 05:59
@Xreki Xreki added this to Performance Tuning (DONE) in Inference Framework Apr 3, 2018
@Xreki Xreki moved this from Performance Tuning (DONE) to Support FP16 in Inference Framework Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
预测 原名Inference,包含Capi预测问题等
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

float16 support for batch norm operator
2 participants