runtime_graph.h 1.8 KB
Newer Older
L
LiYuRio 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
16
#include <memory>
17
#include <string>
18 19 20 21 22
#include <unordered_map>
#include <vector>
#include "paddle/fluid/distributed/fleet_executor/fleet_executor_desc.pb.h"
#include "paddle/fluid/framework/op_proto_maker.h"
#include "paddle/fluid/platform/macros.h"
L
LiYuRio 已提交
23 24 25

namespace paddle {
namespace distributed {
26
class TaskNode;
L
LiYuRio 已提交
27 28 29 30 31

class RuntimeGraph final {
 public:
  RuntimeGraph() = default;
  ~RuntimeGraph() = default;
32 33
  const std::unordered_map<int64_t, TaskNode*>& interceptor_id_to_node() const {
    return interceptor_id_to_node_;
34
  }
35 36
  const std::unordered_map<int64_t, int64_t>& interceptor_id_to_rank() const {
    return interceptor_id_to_rank_;
37
  }
38
  void SetInterceptorIdToRank(
39 40
      const std::unordered_map<int64_t, int64_t>& interceptor_id_to_rank) {
    interceptor_id_to_rank_ = interceptor_id_to_rank;
41 42
  }
  void SetInterceptorIdToNode(
43 44
      const std::unordered_map<int64_t, TaskNode*>& interceptor_id_to_node) {
    interceptor_id_to_node_ = interceptor_id_to_node;
45
  }
46
  std::string DebugString() const;
L
LiYuRio 已提交
47

48
 private:
L
LiYuRio 已提交
49
  DISABLE_COPY_AND_ASSIGN(RuntimeGraph);
50 51
  std::unordered_map<int64_t, TaskNode*> interceptor_id_to_node_;
  std::unordered_map<int64_t, int64_t> interceptor_id_to_rank_;
L
LiYuRio 已提交
52 53 54 55
};

}  // namespace distributed
}  // namespace paddle