Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into winters006
Browse files Browse the repository at this point in the history
  • Loading branch information
WintersMontagne10335 committed Sep 30, 2023
2 parents 1635319 + a46df40 commit 5360925
Show file tree
Hide file tree
Showing 51 changed files with 1,559 additions and 744 deletions.
5 changes: 0 additions & 5 deletions paddle/fluid/distributed/auto_parallel/spmd_rules/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "paddle/fluid/distributed/auto_parallel/spmd_rules/common.h"
#include "paddle/fluid/distributed/auto_parallel/spmd_rules/cross_entropy_with_softmax_spmd_rule.h"
#include "paddle/fluid/distributed/auto_parallel/spmd_rules/replicated_spmd_rule.h"
#include "paddle/fluid/distributed/auto_parallel/spmd_rules/softmax_spmd_rule.h"

// TODO(ljz) Automatic this process in cmake file.
namespace paddle {
Expand All @@ -27,10 +26,6 @@ namespace auto_parallel {
// replicated rule
REGISTER_SPMD_RULE(replicated, ReplicatedSPMDRule);

// softmax rule
REGISTER_SPMD_RULE(softmax, SoftmaxSPMDRule);
REGISTER_SPMD_RULE(log_softmax, SoftmaxSPMDRule);

// cross_entropy_with_softmax
REGISTER_SPMD_RULE(cross_entropy_with_softmax, CrossEntropyWithSoftmaxSPMDRule);
REGISTER_SPMD_RULE(softmax_with_cross_entropy, CrossEntropyWithSoftmaxSPMDRule);
Expand Down
179 changes: 0 additions & 179 deletions paddle/fluid/distributed/auto_parallel/spmd_rules/softmax_spmd_rule.cc

This file was deleted.

4 changes: 1 addition & 3 deletions paddle/fluid/eager/to_static/run_program_op_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ inline void newir_run_program_ad_func(
// Set TensorWrappers
grad_node->SetFwdX(filter_x);

auto filter_params =
newir_filter_unused_input_var_in_backward(params, "bp", attrs);
grad_node->SetFwdParams(filter_params);
grad_node->SetFwdParams(params);

grad_node->SetStepScope(step_scope); // just for set useable.

Expand Down
26 changes: 14 additions & 12 deletions paddle/fluid/eager/to_static/run_program_op_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,23 @@ static void ShareTensorsIntoScopeWithName(
}

static auto GetNameFromValue(const ::pir::Block *block,
const std::vector<::pir::Value> &values) {
const std::vector<::pir::Value> &values,
bool is_input) {
// we use name here, later value is used directly.
std::unordered_map<::pir::Value, std::string> value2name;
for (auto *op : *block) {
std::string name;
if (op->name() == "pd_op.data") {
if (is_input && op->name() == "pd_op.data") {
name =
op->attributes().at("name").dyn_cast<pir::StrAttribute>().AsString();
value2name[op->results()[0].Value::impl()] = name;
} else if (op->name() == "builtin.set_parameter") {
} else if (!is_input && op->name() == "builtin.set_parameter") {
name = op->attributes()
.at("parameter_name")
.dyn_cast<pir::StrAttribute>()
.AsString();
value2name[op->operand(0).source()] = name;
} else if (op->name() == "builtin.get_parameter") {
} else if (is_input && op->name() == "builtin.get_parameter") {
name = op->attributes()
.at("parameter_name")
.dyn_cast<pir::StrAttribute>()
Expand Down Expand Up @@ -256,7 +257,7 @@ static void ShareTensorsIntoScopeByValue(
const std::vector<Tensor> &tensors,
const std::vector<::pir::Value> &values,
paddle::framework::Scope *scope) {
auto names = GetNameFromValue(block, values);
auto names = GetNameFromValue(block, values, true);
if (VLOG_IS_ON(4)) {
for (auto &s : names) {
VLOG(4) << "ShareTensorIntoScopeByValue name: " << s;
Expand All @@ -270,7 +271,7 @@ static void ShareTensorsFromScopeByValue(
const std::vector<Tensor *> &tensors,
const std::vector<::pir::Value> &values,
paddle::framework::Scope *scope) {
auto names = GetNameFromValue(block, values);
auto names = GetNameFromValue(block, values, false);
for (size_t i = 0; i < tensors.size(); ++i) {
auto &name = names[i];
auto &value = values[i];
Expand Down Expand Up @@ -506,15 +507,16 @@ inline void NewIRRunProgramAPI(

// update interpretercore skip_gc_var
auto skip_names =
details::GetNameFromValue(forward_global_block, middle_values);
details::GetNameFromValue(forward_global_block, middle_values, false);
auto skip_names_set =
std::set<std::string>(skip_names.begin(), skip_names.end());
skip_names = details::GetNameFromValue(forward_global_block, output_values);
skip_names =
details::GetNameFromValue(forward_global_block, output_values, false);
skip_names_set.insert(skip_names.begin(), skip_names.end());
auto no_need_buffer_values = PADDLE_GET_CONST(std::vector<::pir::Value>,
attrs.at("no_need_buffers"));
auto no_need_buffer_names =
details::GetNameFromValue(forward_global_block, no_need_buffer_values);
auto no_need_buffer_names = details::GetNameFromValue(
forward_global_block, no_need_buffer_values, false);
VLOG(4) << "start skip no need buffer vars with name:";
for (auto &name : no_need_buffer_names) {
VLOG(4) << "Skip no need buffer vars with name:" << name;
Expand Down Expand Up @@ -1053,10 +1055,10 @@ inline void NewIRRunProgramGradAPI(
// get all eager gc vars
std::set<std::string> skip_eager_delete_vars;
auto skip_names =
details::GetNameFromValue(backward_global_block, x_grad_values);
details::GetNameFromValue(backward_global_block, x_grad_values, false);
skip_eager_delete_vars.insert(skip_names.begin(), skip_names.end());
skip_names =
details::GetNameFromValue(backward_global_block, p_grad_values);
details::GetNameFromValue(backward_global_block, p_grad_values, false);
skip_eager_delete_vars.insert(skip_names.begin(), skip_names.end());
interpreter_core->SetSkipGcVars(skip_eager_delete_vars);
interpretercore_info_cache.UpdateSkipEagerDeleteVars(
Expand Down
Loading

0 comments on commit 5360925

Please sign in to comment.