-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[fleet exe] supprot fp16 feed and fetch on cpp side #39758
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
[fleet exe] supprot fp16 feed and fetch on cpp side #39758
Conversation
@@ -52,6 +52,8 @@ bool LoadDataFromDistModelTensor(const DistModelTensor &input_data, | |||
input_tensor_ptr = input_tensor->mutable_data<float>(dims, place); | |||
} else if (input_data.dtype == DistModelDataType::INT32) { | |||
input_tensor_ptr = input_tensor->mutable_data<int32_t>(dims, place); | |||
} else if (input_data.dtype == DistModelDataType::FLOAT16) { | |||
input_tensor_ptr = input_tensor->mutable_data<float16>(dims, place); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float16后面加上命名空间吧
@@ -503,9 +507,13 @@ bool DistModel::FetchResults(std::vector<DistModelTensor> *output_data, | |||
} else if (type == framework::proto::VarType::INT32) { | |||
rst = FetchResult<int32_t>(fetch, output); | |||
output->dtype = DistModelDataType::INT32; | |||
} else if (type == framework::proto::VarType::FP16) { | |||
rst = FetchResult<float16>(fetch, output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
// Note: use same enum number of float16 in numpy. | ||
// import numpy as np | ||
// print np.dtype(np.float16).num # 23 | ||
constexpr int NPY_FLOAT16_ = 23; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NPY_FLOAT16是不是numpy的一个枚举
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是,但是拿不到这个enum,只能用enum对应的int来弄了。就是说以后如果numpy改了enum的顺序,这个hard code的值要跟着改。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
Others
Describe
support fp16 feed and fetch