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

Method LookupOrCreate

tensorflow/core/framework/resource_mgr.h:640–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638
639template <typename T, bool use_dynamic_cast>
640Status ResourceMgr::LookupOrCreate(const string& container, const string& name,
641 T** resource,
642 std::function<Status(T**)> creator) {
643 CheckDeriveFromResourceBase<T>();
644 *resource = nullptr;
645 Status s;
646 {
647 tf_shared_lock l(mu_);
648 s = LookupInternal<T, use_dynamic_cast>(container, name, resource);
649 if (s.ok()) return s;
650 }
651 mutex_lock l(mu_);
652 s = LookupInternal<T, use_dynamic_cast>(container, name, resource);
653 if (s.ok()) return s;
654 TF_RETURN_IF_ERROR(creator(resource));
655 s = DoCreate(container, MakeTypeIndex<T>(), name, *resource);
656 if (!s.ok()) {
657 return errors::Internal("LookupOrCreate failed unexpectedly");
658 }
659 (*resource)->Ref();
660 return s;
661}
662
663template <typename T>
664Status ResourceMgr::Delete(const string& container, const string& name) {

Callers 10

LookupOrCreateResourceFunction · 0.45
GetScratchFunction · 0.45
operator()Method · 0.45
operator()Method · 0.45
ComputeAsyncMethod · 0.45
ComputeAsyncMethod · 0.45
ComputeAsyncMethod · 0.45
ComputeAsyncMethod · 0.45
operator()Method · 0.45
lookupMethod · 0.45

Calls 3

InternalFunction · 0.85
okMethod · 0.45
RefMethod · 0.45

Tested by

no test coverage detected