| 44 | } |
| 45 | |
| 46 | void TensorList::Encode(VariantTensorData* data) const { |
| 47 | data->set_type_name(TypeName()); |
| 48 | std::vector<size_t> invalid_indices; |
| 49 | for (size_t i = 0; i < tensors().size(); i++) { |
| 50 | if (tensors().at(i).dtype() != DT_INVALID) { |
| 51 | *data->add_tensors() = tensors().at(i); |
| 52 | } else { |
| 53 | invalid_indices.push_back(i); |
| 54 | } |
| 55 | } |
| 56 | string metadata; |
| 57 | // TODO(b/118838800): Add a proto for storing the metadata. |
| 58 | // Metadata format: |
| 59 | // <num_invalid_tensors><invalid_indices><element_dtype><element_shape_proto> |
| 60 | core::PutVarint64(&metadata, static_cast<uint64>(invalid_indices.size())); |
| 61 | for (size_t i : invalid_indices) { |
| 62 | core::PutVarint64(&metadata, static_cast<uint64>(i)); |
| 63 | } |
| 64 | core::PutVarint64(&metadata, static_cast<uint64>(element_dtype)); |
| 65 | core::PutVarint64(&metadata, static_cast<uint64>(max_num_elements)); |
| 66 | TensorShapeProto element_shape_proto; |
| 67 | element_shape.AsProto(&element_shape_proto); |
| 68 | element_shape_proto.AppendToString(&metadata); |
| 69 | data->set_metadata(metadata); |
| 70 | } |
| 71 | |
| 72 | static Status TensorListDeviceCopy( |
| 73 | const TensorList& from, TensorList* to, |
nothing calls this directly
no test coverage detected