Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove batch norm from StaticBuildBlackList #57510

Merged
merged 15 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion paddle/fluid/framework/new_executor/interpreter/static_build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ std::set<std::string> OpsCanSkipedFakeAllocInStaticBuild = {
"nop"};

std::set<std::string> StaticBuildBlackList = {
"batch_norm" /*: to handle reserve_space output*/,
"cinn_instruction_run" /*: to handle subgraph infermeta*/,
"cinn_launch" /*: to handle subgraph infermeta*/,
"run_program" /*: to handle scope output*/,
Expand Down Expand Up @@ -206,6 +205,14 @@ bool TensorShouldBeFakeInitialized(const OperatorBase& op,
}
}

if (op_type == "batch_norm" && parameter_name == "ReserveSpace") {
if (dynamic_cast<const OperatorWithKernel*>(&op)->kernel_type()->place_ ==
phi::CPUPlace()) {
VLOG(2) << "Skip fake initialization for: " << parameter_name;
return false;
}
}

if (op_type == "coalesce_tensor" && parameter_name == "Output") {
VLOG(2) << "Skip fake initialization for: " << parameter_name;
return false;
Expand Down Expand Up @@ -250,6 +257,12 @@ bool TensorShouldBeFakeInitialized(const OperatorBase& op,
}
}

if ((op_type == "flatten" || op_type == "flatten_contiguous_range") &&
parameter_name == "XShape") {
VLOG(2) << "Skip fake initialization for: " << parameter_name;
return false;
}

if (op_type == "segment_pool" && parameter_name == "SummedIds") {
return op.Attr<std::string>("pooltype") == "MEAN" &&
dynamic_cast<const OperatorWithKernel*>(&op)
Expand Down Expand Up @@ -856,6 +869,8 @@ void FakeInitializeOutputsForFunctionKernel(
dtype = InferDTypeFromAttr(op, runtime_ctx, "dtype");
} else if (op_type == "bincount" || op_type == "reduce_sum_grad") {
dtype = GetInputDType(runtime_ctx, "X");
} else if (op_type == "dequantize_linear") {
dtype = GetInputDType(runtime_ctx, "Scale");
} else if (op_type == "lamb") {
bool multi_precision = op.Attr<bool>("multi_precision");
dtype = GetInputDType(runtime_ctx, "Moment1");
Expand Down
Loading