Skip to content

Commit

Permalink
Sort input in PreProcessPrediction
Browse files Browse the repository at this point in the history
  • Loading branch information
zhjunqin committed Nov 4, 2020
1 parent c1a2a5b commit 7916b6d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tensorflow_serving/servables/tensorflow/predict_util.cc
Expand Up @@ -111,6 +111,13 @@ Status PreProcessPrediction(const SignatureDef& signature,
}
inputs->emplace_back(std::make_pair(iter->second.name(), tensor));
}
// Sort inputs to make TF session not insert too many keys to executor
std::sort(
inputs->begin(), inputs->end(),
[](std::pair<string, Tensor> &left, std::pair<string, Tensor> &right) {
return left.first < right.first;
}
);

// Prepare run target.
std::set<string> seen_outputs;
Expand All @@ -134,6 +141,7 @@ Status PreProcessPrediction(const SignatureDef& signature,
output_tensor_names->emplace_back(iter->second.name());
output_tensor_aliases->emplace_back(alias);
}

// When no output is specified, fetch all output tensors specified in
// the signature.
if (output_tensor_names->empty()) {
Expand All @@ -142,6 +150,7 @@ Status PreProcessPrediction(const SignatureDef& signature,
output_tensor_aliases->emplace_back(iter.first);
}
}

return Status::OK();
}

Expand Down

0 comments on commit 7916b6d

Please sign in to comment.