|
|
|
@ -650,9 +650,9 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
[](ir::Pass &self, const std::string &name, const std::string &attr) {
|
|
|
|
|
self.Set<std::string>(name, new std::string(attr));
|
|
|
|
|
})
|
|
|
|
|
.def("set_int", [](ir::Pass &self, const std::string &name, int val) {
|
|
|
|
|
self.Set<const int>(name, new int(val));
|
|
|
|
|
});
|
|
|
|
|
.def("set_int", [](ir::Pass &self, const std::string &name,
|
|
|
|
|
int val) { self.Set<const int>(name, new int(val)); })
|
|
|
|
|
.def("type", &ir::Pass::Type);
|
|
|
|
|
|
|
|
|
|
py::class_<ir::PassBuilder, std::shared_ptr<ir::PassBuilder>> pb(
|
|
|
|
|
m, "PassBuilder");
|
|
|
|
@ -791,6 +791,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
"reduce_strategy",
|
|
|
|
|
[](const BuildStrategy &self) { return self.reduce_; },
|
|
|
|
|
[](BuildStrategy &self, BuildStrategy::ReduceStrategy strategy) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.reduce_ = strategy;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is STR, there are two reduce strategies in ParallelExecutor,
|
|
|
|
@ -804,6 +805,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
[](const BuildStrategy &self) { return self.gradient_scale_; },
|
|
|
|
|
[](BuildStrategy &self,
|
|
|
|
|
BuildStrategy::GradientScaleStrategy strategy) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.gradient_scale_ = strategy;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is STR, there are three ways of defining :math:`loss@grad` in
|
|
|
|
@ -815,6 +817,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
"debug_graphviz_path",
|
|
|
|
|
[](const BuildStrategy &self) { return self.debug_graphviz_path_; },
|
|
|
|
|
[](BuildStrategy &self, const std::string &path) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.debug_graphviz_path_ = path;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is STR, debug_graphviz_path indicate the path that
|
|
|
|
@ -824,6 +827,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
"enable_data_balance",
|
|
|
|
|
[](const BuildStrategy &self) { return self.enable_data_balance_; },
|
|
|
|
|
[](BuildStrategy &self, bool b) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.enable_data_balance_ = b;
|
|
|
|
|
}) // FIXME(chengudo): enable_data_balance seems not important
|
|
|
|
|
.def_property(
|
|
|
|
@ -832,6 +836,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
return self.enable_sequential_execution_;
|
|
|
|
|
},
|
|
|
|
|
[](BuildStrategy &self, bool b) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.enable_sequential_execution_ = b;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is BOOL. If set True, the execution order of ops would be the same as what is in the program. Default False.)DOC")
|
|
|
|
@ -841,6 +846,7 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
return self.remove_unnecessary_lock_;
|
|
|
|
|
},
|
|
|
|
|
[](BuildStrategy &self, bool b) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.remove_unnecessary_lock_ = b;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is BOOL. If set True, some locks in GPU ops would be released and ParallelExecutor would run faster. Default False.)DOC")
|
|
|
|
@ -850,15 +856,19 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
return self.fuse_elewise_add_act_ops_;
|
|
|
|
|
},
|
|
|
|
|
[](BuildStrategy &self, bool b) {
|
|
|
|
|
PADDLE_ENFORCE(!self.IsFinalized(), "BuildStrategy is finlaized.");
|
|
|
|
|
self.fuse_elewise_add_act_ops_ = b;
|
|
|
|
|
},
|
|
|
|
|
R"DOC(The type is BOOL, fuse_elewise_add_act_ops indicate whether
|
|
|
|
|
to fuse elementwise_add_op and activation_op,
|
|
|
|
|
it may make the execution faster. Default False)DOC")
|
|
|
|
|
.def("_create_passes_from_strategy",
|
|
|
|
|
.def("_finalize_strategy_and_create_passes",
|
|
|
|
|
[](BuildStrategy &self) -> std::shared_ptr<ir::PassBuilder> {
|
|
|
|
|
return self.CreatePassesFromStrategy();
|
|
|
|
|
});
|
|
|
|
|
return self.CreatePassesFromStrategy(true);
|
|
|
|
|
},
|
|
|
|
|
R"DOC(Allow user to customized passes. Normally model-specific
|
|
|
|
|
optimization passes should be defined in this way. BuildStrategy
|
|
|
|
|
cannot be updated after being finalized.)DOC");
|
|
|
|
|
|
|
|
|
|
pe.def(py::init<const std::vector<platform::Place> &,
|
|
|
|
|
const std::unordered_set<std::string> &,
|
|
|
|
|