Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

inference using fp16 for c++ api #14714

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/c_api/c_predict_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,26 @@ int _CreatePartialOut(const char* symbol_json_str,

std::vector<NDArray> arg_arrays, aux_arrays;
for (size_t i = 0; i < arg_shapes.size(); ++i) {
NDArray nd = NDArray(arg_shapes[i], ctx);
if (arg_params.count(arg_names[i]) != 0) {
int dtype = arg_params[arg_names[i]].dtype();
NDArray nd = NDArray(arg_shapes[i], ctx, false, dtype);
CopyFromTo(arg_params[arg_names[i]], &nd);
arg_arrays.push_back(nd);
} else {
NDArray nd = NDArray(arg_shapes[i], ctx);
arg_arrays.push_back(nd);
Copy link
Contributor

Choose a reason for hiding this comment

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

can this line be moved to after the if-else instead of adding in if separately and else separately?

}
arg_arrays.push_back(nd);
}
for (size_t i = 0; i < aux_shapes.size(); ++i) {
NDArray nd = NDArray(aux_shapes[i], ctx);
if (aux_params.count(aux_names[i]) != 0) {
int dtype = aux_params[aux_names[i]].dtype();
NDArray nd = NDArray(aux_shapes[i], ctx, false, dtype);
CopyFromTo(aux_params[aux_names[i]], &nd);
aux_arrays.push_back(nd);
} else {
NDArray nd = NDArray(aux_shapes[i], ctx);
aux_arrays.push_back(nd);
Copy link
Contributor

Choose a reason for hiding this comment

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

can this line be moved to after the if-else instead of adding in if separately and else separately?

}
aux_arrays.push_back(nd);
}
// bind
for (int i = 0; i < num_threads; i++) {
Expand Down