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

Method CreateHandle

tensorflow/core/common_runtime/pending_counts.h:375–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373};
374
375inline PendingCounts::Handle PendingCounts::Layout::CreateHandle(
376 size_t max_pending_count, size_t max_dead_count) {
377 Handle result;
378 if ((max_pending_count > kMaxCountForPackedCounts) ||
379 (max_dead_count > kMaxCountForPackedCounts)) {
380 constexpr int B = sizeof(std::atomic<LargeCounts>);
381 // Round byte offset to proper alignment
382 static_assert(
383 sizeof(std::atomic<LargeCounts>) >= alignof(std::atomic<LargeCounts>),
384 "std::atomic<LargeCounts> must be packed");
385 int64_t offset = ((static_cast<int64_t>(next_offset_) + B - 1) / B) * B;
386 result.byte_offset_ = offset;
387 result.is_large_ = true;
388 next_offset_ = result.byte_offset_ + B;
389 } else {
390 result.byte_offset_ = next_offset_;
391 result.is_large_ = false;
392 static_assert(sizeof(std::atomic<PackedCounts>) == 1,
393 "std::atomic<PackedCounts> should be a single byte");
394 next_offset_ += sizeof(std::atomic<PackedCounts>);
395 }
396 return result;
397}
398
399} // end namespace tensorflow
400

Callers 2

TESTFunction · 0.80
InitializeMethod · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64