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

Method Encode

tensorflow/core/kernels/list_kernels.cc:46–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void 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
72static Status TensorListDeviceCopy(
73 const TensorList& from, TensorList* to,

Callers

nothing calls this directly

Calls 11

TypeNameFunction · 0.85
tensorsFunction · 0.85
PutVarint64Function · 0.85
set_type_nameMethod · 0.80
sizeMethod · 0.45
dtypeMethod · 0.45
atMethod · 0.45
add_tensorsMethod · 0.45
push_backMethod · 0.45
AsProtoMethod · 0.45
set_metadataMethod · 0.45

Tested by

no test coverage detected