multi_devices_helper.h 1.9 KB
Newer Older
Y
Yu Yang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//   Copyright (c) 2018 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

Y
Yu Yang 已提交
17 18
#include <memory>
#include <string>
X
Xin Pan 已提交
19
#include <vector>
Y
Yu Yang 已提交
20

X
clean  
Xin Pan 已提交
21 22 23
#include "paddle/fluid/framework/details/op_handle_base.h"
#include "paddle/fluid/framework/details/var_handle.h"

Y
Yu Yang 已提交
24 25 26
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/platform/place.h"

X
Xin Pan 已提交
27
#include "paddle/fluid/framework/ir/graph.h"
28
#include "paddle/fluid/framework/ir/pass.h"
X
Xin Pan 已提交
29

Y
Yu Yang 已提交
30 31 32 33
namespace paddle {
namespace framework {
namespace details {

X
clean  
Xin Pan 已提交
34 35 36 37
// all variable in each devices.
// The outside vector is the device vector. Each element of this vector is a
// map from variable name to variables. The variables, who have the same name,
// will have a differsent version. The offset in the
X
Xin Pan 已提交
38
// `std::vector<VarHandle*>` is the version of varaibles.
Y
Yancey1989 已提交
39
typedef std::vector<std::unordered_map<std::string, std::vector<VarHandle *>>>
X
Xin Pan 已提交
40
    GraphVars;
X
Xin Pan 已提交
41
const char kGraphVars[] = "vars";
X
clean  
Xin Pan 已提交
42 43

// aux variables to represent dependency. Useful to resolve data hazard.
Y
Yancey1989 已提交
44
typedef std::unordered_set<VarHandleBase *> GraphDepVars;
X
Xin Pan 已提交
45
const char kGraphDepVars[] = "dep_vars";
Y
Yancey1989 已提交
46 47 48 49 50 51 52

// TODO(panyx0718): Clean this up as well.
// all operators. NOTE that even we use a vector here, the operators is
// unordered.
typedef std::vector<OpHandleBase *> GraphOps;
const char kGraphOps[] = "ops";

Y
Yu Yang 已提交
53 54 55
}  // namespace details
}  // namespace framework
}  // namespace paddle