Home | History | Annotate | Download | only in distributed_runtime
      1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_SESSION_H_
     17 #define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_SESSION_H_
     18 
     19 #include <string>
     20 
     21 #include "tensorflow/core/common_runtime/device_mgr.h"
     22 #include "tensorflow/core/distributed_runtime/cluster_function_library_runtime.h"
     23 #include "tensorflow/core/distributed_runtime/graph_mgr.h"
     24 #include "tensorflow/core/distributed_runtime/worker_cache.h"
     25 
     26 namespace tensorflow {
     27 
     28 class ClusterFunctionLibraryRuntime;
     29 class GraphMgr;
     30 class WorkerCacheInterface;
     31 
     32 // WorkerSession encapsulates all of the state relating to a given session.
     33 struct WorkerSession {
     34   // The name of the session.
     35   const string session_name;
     36 
     37   // The name of the worker. E.g., /job:mnist/replica:0/task:1.
     38   const string worker_name;
     39 
     40   // Object from which WorkerInterface instances can be obtained.
     41   const std::unique_ptr<WorkerCacheInterface> worker_cache;
     42 
     43   // Collection of local devices. These devices are typically RenamedDevices
     44   // in all except the SessionMgr.legacy_session_. legacy_session_.device_mgr
     45   // == worker_env_.device_mgr, which holds the true devices.
     46   const std::unique_ptr<DeviceMgr> device_mgr;
     47 
     48   // graph_mgr keeps track of the registered graphs of this session.
     49   //
     50   // Note: graph_mgr must be deleted before rendezvous_mgr!
     51   // Note: graph_mgr must be deleted before device_mgr!
     52   const std::unique_ptr<GraphMgr> graph_mgr;
     53 
     54   std::unique_ptr<ClusterFunctionLibraryRuntime> cluster_flr;
     55 
     56   WorkerSession(const string& session_name, const string& worker_name,
     57                 std::unique_ptr<WorkerCacheInterface> worker_cache,
     58                 std::unique_ptr<DeviceMgr> device_mgr,
     59                 std::unique_ptr<GraphMgr> graph_mgr);
     60 };
     61 
     62 }  // namespace tensorflow
     63 
     64 #endif  // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_WORKER_SESSION_H_
     65