| 86 | } |
| 87 | |
| 88 | bool 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 |
no test coverage detected