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

Function DecodeVariantList

tensorflow/core/framework/variant.cc:88–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88bool DecodeVariantList(std::unique_ptr<port::StringListDecoder> d,
89 Variant* variant_array, int64 n) {
90 std::vector<uint32> sizes(n);
91 if (!d->ReadSizes(&sizes)) return false;
92
93 for (int i = 0; i < n; ++i) {
94 if (variant_array[i].is_empty()) {
95 variant_array[i] = VariantTensorDataProto();
96 }
97 // TODO(ebrevdo): Replace with StringPiece? Any way to make this a
98 // zero-copy operation that keeps a reference to the data in d?
99 string str(d->Data(sizes[i]), sizes[i]);
100 if (!variant_array[i].Decode(std::move(str))) return false;
101 if (!DecodeUnaryVariant(&variant_array[i])) {
102 LOG(ERROR) << "Could not decode variant with type_name: \""
103 << variant_array[i].TypeName()
104 << "\". Perhaps you forgot to register a "
105 "decoder via REGISTER_UNARY_VARIANT_DECODE_FUNCTION?";
106 return false;
107 }
108 }
109 return true;
110}
111
112} // end namespace tensorflow

Callers 1

DecodeMethod · 0.85

Calls 7

DecodeUnaryVariantFunction · 0.85
ReadSizesMethod · 0.45
is_emptyMethod · 0.45
DataMethod · 0.45
DecodeMethod · 0.45
TypeNameMethod · 0.45

Tested by

no test coverage detected