MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseAny

Function ParseAny

tensorflow/core/platform/protobuf_internal.h:43–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41// Utility for parsing an Any value with full or lite protos.
42template <class T>
43Status ParseAny(const google::protobuf::Any& any, T* message,
44 const string& type_name) {
45#ifdef TENSORFLOW_LITE_PROTOS
46 if (any.type_url() != strings::StrCat("type.googleapis.com/", type_name)) {
47 return errors::FailedPrecondition(
48 "Expected Any type_url for: ", type_name,
49 ". Got: ", string(any.type_url().data(), any.type_url().size()), ".");
50 }
51 if (!message->ParseFromString(any.value())) {
52 return errors::FailedPrecondition("Failed to unpack: ",
53 DebugStringIfAvailable(any));
54 }
55#else
56 CHECK_EQ(type_name, message->descriptor()->full_name());
57 if (!any.Is<T>()) {
58 return errors::FailedPrecondition(
59 "Expected Any type_url for: ", message->descriptor()->full_name(),
60 ". Got: ", string(any.type_url().data(), any.type_url().size()), ".");
61 }
62 if (!any.UnpackTo(message)) {
63 return errors::FailedPrecondition("Failed to unpack: ",
64 DebugStringIfAvailable(any));
65 }
66#endif
67 return Status::OK();
68}
69
70} // namespace tensorflow
71

Callers 5

GetAssetFileDefsFunction · 0.85
GetSignaturesFunction · 0.85
GetAssetFileDefsFunction · 0.85

Calls 8

FailedPreconditionFunction · 0.85
DebugStringIfAvailableFunction · 0.85
StrCatFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
ParseFromStringMethod · 0.45
valueMethod · 0.45
full_nameMethod · 0.45

Tested by

no test coverage detected