tensorflow-core-framework-function_handle_cache.h 2019-06-10 339 tensorflow-core-framework ```cpp #ifndef TENSORFLOW_CORE_FRAMEWORK_FUNCTION_HANDLE_CACHE_H_ #define TENSORFLOW_CORE_FRAMEWORK_FUNCTION_HANDLE_CACHE_H_ #include #include "tensorflow/core/framework/function.h" namespace tensorflow { namespace data { class FunctionHandleCache { public: explicit FunctionHandleCache(FunctionLibraryRuntime* lib); ~FunctionHandleCache(); // Looks up the function to be instantiated in the cache first. If present, // returns handle from there. Otherwise, instantiates a new function // and stores handle in the cache. Status Instantiate(const string& function_name, AttrSlice attrs, FunctionLibraryRuntime::InstantiateOptions options, FunctionLibraryRuntime::Handle* handle); // Releases all the handles in the cache, clearing out the state for all // functions involved. Status Clear(); private: mutex mu_; FunctionLibraryRuntime* lib_ = nullptr; // not owned const string state_handle_; std::unordered_map handles_ GUARDED_BY(mu_); }; } // namespace data } // namespace tensorflow #endif // TENSORFLOW_CORE_FRAMEWORK_FUNCTION_HANDLE_CACHE_H_ ``` 本文链接: http://codeeyes.net/archives/tensorflow-core-framework-function_handle_cache_h.html