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

Function DecodeUnaryVariant

tensorflow/core/framework/variant_op_registry.cc:60–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool DecodeUnaryVariant(Variant* variant) {
61 CHECK_NOTNULL(variant);
62 if (variant->TypeName().empty()) {
63 VariantTensorDataProto* t = variant->get<VariantTensorDataProto>();
64 if (t == nullptr || !t->metadata().empty() || !t->tensors().empty()) {
65 // Malformed variant.
66 return false;
67 } else {
68 // Serialization of an empty Variant.
69 variant->clear();
70 return true;
71 }
72 }
73 UnaryVariantOpRegistry::VariantDecodeFn* decode_fn =
74 UnaryVariantOpRegistry::Global()->GetDecodeFn(variant->TypeName());
75 if (decode_fn == nullptr) {
76 return false;
77 }
78 const string type_name = variant->TypeName();
79 bool decoded = (*decode_fn)(variant);
80 if (!decoded) return false;
81 if (variant->TypeName() != type_name) {
82 LOG(ERROR) << "DecodeUnaryVariant: Variant type_name before decoding was: "
83 << type_name
84 << " but after decoding was: " << variant->TypeName()
85 << ". Treating this as a failure.";
86 return false;
87 }
88 return true;
89}
90
91// Add some basic registrations for use by others, e.g., for testing.
92

Callers 4

FromProtoField<Variant>Function · 0.85
DecodeVariantListFunction · 0.85
TESTFunction · 0.85
ReadVariantTensorFunction · 0.85

Calls 6

metadataMethod · 0.80
tensorsMethod · 0.80
GetDecodeFnMethod · 0.80
emptyMethod · 0.45
TypeNameMethod · 0.45
clearMethod · 0.45

Tested by 1

TESTFunction · 0.68