Skip to content

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
@kexinzhao kexinzhao requested a review from jacquesqiao March 19, 2018 04:39
auto *saved_variance = ctx.Output<Tensor>("SavedVariance");

// 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

预测 原名Inference,包含Capi预测问题等

Projects

None yet

Development

Successfully merging this pull request may close these issues.

float16 support for batch norm operator

2 participants