| 69 | } |
| 70 | |
| 71 | Allocator* AllocatorFactoryRegistry::GetAllocator() { |
| 72 | mutex_lock l(mu_); |
| 73 | first_alloc_made_ = true; |
| 74 | FactoryEntry* best_entry = nullptr; |
| 75 | for (auto& entry : factories_) { |
| 76 | if (best_entry == nullptr) { |
| 77 | best_entry = &entry; |
| 78 | } else if (entry.priority > best_entry->priority) { |
| 79 | best_entry = &entry; |
| 80 | } |
| 81 | } |
| 82 | if (best_entry) { |
| 83 | if (!best_entry->allocator) { |
| 84 | best_entry->allocator.reset(best_entry->factory->CreateAllocator()); |
| 85 | } |
| 86 | return best_entry->allocator.get(); |
| 87 | } else { |
| 88 | LOG(FATAL) << "No registered CPU AllocatorFactory"; |
| 89 | return nullptr; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #ifdef TENSORFLOW_USE_PMEM |
| 94 | Allocator* AllocatorFactoryRegistry::GetExperimentalPMEMAllocator( |