| 47 | } // namespace |
| 48 | |
| 49 | Status GetSignatures(const tensorflow::MetaGraphDef& meta_graph_def, |
| 50 | Signatures* signatures) { |
| 51 | const auto& collection_def = meta_graph_def.collection_def(); |
| 52 | const auto it = collection_def.find(kSignaturesKey); |
| 53 | if (it == collection_def.end() || it->second.any_list().value_size() != 1) { |
| 54 | return errors::FailedPrecondition( |
| 55 | strings::StrCat("Expected exactly one signatures proto in : ", |
| 56 | DebugStringIfAvailable(meta_graph_def))); |
| 57 | } |
| 58 | const auto& any = it->second.any_list().value(0); |
| 59 | return ParseAny(any, signatures, "tensorflow.serving.Signatures"); |
| 60 | } |
| 61 | |
| 62 | Status SetSignatures(const Signatures& signatures, |
| 63 | tensorflow::MetaGraphDef* meta_graph_def) { |