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

Method Add

tensorflow/core/util/tensor_bundle/tensor_bundle.cc:425–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423}
424
425Status BundleWriter::Add(StringPiece key, const Tensor& val) {
426 if (!status_.ok()) return status_;
427 CHECK_NE(key, kHeaderEntryKey);
428 const string key_string(key);
429 if (entries_.find(key_string) != entries_.end()) {
430 status_ = errors::InvalidArgument("Adding duplicate key: ", key);
431 return status_;
432 }
433
434 BundleEntryProto* entry = &entries_[key_string];
435 entry->set_dtype(val.dtype());
436 val.shape().AsProto(entry->mutable_shape());
437 entry->set_shard_id(0);
438 entry->set_offset(size_);
439
440 // Updates the data file.
441 size_t data_bytes_written = 0;
442 uint32 crc32c = 0;
443 out_->clear_crc32c();
444 if (val.dtype() == DT_STRING) {
445 status_ = WriteStringTensor(val, out_.get(), &data_bytes_written, &crc32c);
446 } else if (val.dtype() == DT_VARIANT) {
447 status_ = WriteVariantTensor(val, out_.get(), &data_bytes_written, &crc32c);
448 } else {
449 status_ = WriteTensor(val, out_.get(), &data_bytes_written);
450 crc32c = out_->crc32c();
451 }
452
453 if (status_.ok()) {
454 entry->set_size(data_bytes_written);
455 entry->set_crc32c(crc32c::Mask(crc32c));
456 size_ += data_bytes_written;
457 status_ = PadAlignment(out_.get(), options_.data_alignment, &size_);
458 }
459 return status_;
460}
461
462Status BundleWriter::AddSlice(StringPiece full_tensor_key,
463 const TensorShape& full_tensor_shape,

Callers 10

FlipEndiannessBitFunction · 0.45
TestBasicFunction · 0.45
TestEndiannessFunction · 0.45
TestNonStandardShapesFunction · 0.45
VersionTestFunction · 0.45
TESTFunction · 0.45
TEST_FFunction · 0.45
FinishMethod · 0.45
MergeBundlesFunction · 0.45

Calls 15

InvalidArgumentFunction · 0.85
WriteStringTensorFunction · 0.85
WriteVariantTensorFunction · 0.85
WriteTensorFunction · 0.85
MaskFunction · 0.85
set_offsetMethod · 0.80
clear_crc32cMethod · 0.80
crc32cMethod · 0.80
PadAlignmentFunction · 0.70
okMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by 8

FlipEndiannessBitFunction · 0.36
TestBasicFunction · 0.36
TestEndiannessFunction · 0.36
TestNonStandardShapesFunction · 0.36
VersionTestFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36