diff --git a/paddle/fluid/operators/mean_op.cc b/paddle/fluid/operators/mean_op.cc index 764529a15b6a2b2c98f9ac727d971b8b0b8d1855..83fe1aa6dd1482bfa2a3ba99f488e4ec66d2b49f 100644 --- a/paddle/fluid/operators/mean_op.cc +++ b/paddle/fluid/operators/mean_op.cc @@ -96,7 +96,11 @@ REGISTER_OPERATOR(mean_grad, ops::MeanGradOp, ops::MeanGradNoNeedBufferVarsInferer); REGISTER_OP_CPU_KERNEL( mean, ops::MeanKernel, - ops::MeanKernel); + ops::MeanKernel, + ops::MeanKernel); REGISTER_OP_CPU_KERNEL( mean_grad, ops::MeanGradKernel, - ops::MeanGradKernel); + ops::MeanGradKernel, + ops::MeanGradKernel); diff --git a/paddle/pten/kernels/cpu/math.cc b/paddle/pten/kernels/cpu/math.cc index 25c4671baad7c612c6d6133c4bb1e4ebbbe8d5e9..d63292ba1f5de7bee6f13550f54a447e3279b17b 100644 --- a/paddle/pten/kernels/cpu/math.cc +++ b/paddle/pten/kernels/cpu/math.cc @@ -97,7 +97,8 @@ using complex128 = ::paddle::platform::complex; // using bfloat16 = ::paddle::platform::bfloat16; PT_REGISTER_KERNEL("sign", CPU, ANY, pten::Sign, float, double) {} -PT_REGISTER_KERNEL("mean", CPU, ANY, pten::Mean, float, double) {} +PT_REGISTER_KERNEL( + "mean", CPU, ANY, pten::Mean, float, double, paddle::platform::bfloat16) {} PT_REGISTER_KERNEL("scale", CPU, ANY, diff --git a/python/paddle/fluid/tests/book/test_fit_a_line.py b/python/paddle/fluid/tests/book/test_fit_a_line.py index 8db8b793597bd57e9343af9e37f3cf5150d96225..a8a5c8bf31598c50edd25d8147ce115eb44df985 100644 --- a/python/paddle/fluid/tests/book/test_fit_a_line.py +++ b/python/paddle/fluid/tests/book/test_fit_a_line.py @@ -24,10 +24,19 @@ import unittest import math import sys import os +import struct paddle.enable_static() +def convert_uint16_to_float(in_list): + in_list = numpy.asarray(in_list) + out = numpy.vectorize( + lambda x: struct.unpack('