-
Notifications
You must be signed in to change notification settings - Fork 250
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
float16数据类型支持问题 #1833
Comments
Message that will be displayed on users' first issue |
你提的这个问题很好,我们的代码确实存在问题,我会抽空去看一下。谢谢! |
感谢! 另外,对于async接口,fp16会出现空数据/空指针的情况,原因是以下函数没有处理float16的情况,导致分配的内存为0, 需要增加float16的判断:
Serving/core/predictor/framework/bsf.h Line 209 in 48540ef
Serving/core/predictor/framework/bsf.h Line 1089 in 48540ef
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我们在使用paddle serving并适配自定义硬件类型时,对C++ serving中的float16数据类型有一些问题/疑问:
以
examples/C++/PaddleClas/imagenet
中resnet50 为例client输入float16数据类型问题:
client端对实际的numpy输入并没有做检查/转数,如果prototxt中定义了输入输出类型为float16,但是实际输入采用了numpy.float32,会出现精度问题。
prototxt定义:
实际代码调用:
在client.py中,会根据proto定义的float16数据类型,把
img
转为string数据Serving/python/paddle_serving_client/client.py
Line 438 in cf9ad1d
general_model.cpp中把string数据设置到tensor中,并在之后向server传输。
Serving/core/general-client/src/general_model.cpp
Line 335 in cf9ad1d
但是,img本身为float32数据类型,其内存大小为float16的二倍,不能没有经过转数直接传递到server,否则paddle构建出来的tensor数据错误的:
gdb可以看到输入类型指定为float16时,内存大小却仍然是43224*224=602112
client float16输出问题:
上述案例中,用户代码对输入做转数操作,则会出现pybind解析错误,client代码示例:
使用报错:
因为float16的数据是通过string在client/server中传递的,pybind中要求对C++传递到python端的string数据需要能够被utf-8 decode. 除非用户显示指定返回
py::bytes
不做转换。因此,以下代码是不是需要改为:
return py::bytes(self.get_string_by_name_with_rv(model_idx, name));
Serving/core/general-client/src/pybind_general_model.cpp
Line 63 in cf9ad1d
pybind参考:https://github.com/pybind/pybind11/blob/master/docs/advanced/cast/strings.rst
另外想问下,我们有可供参考的float16运行案例吗?
The text was updated successfully, but these errors were encountered: