Skip to content

Commit

Permalink
Remove has_structed_kerenl and has_fluid_kernel (#56779)
Browse files Browse the repository at this point in the history
* remove has_structed_kerenl and has_fluid_kernel

* add test_fused_layernorm_op to STATIC_BUILD_TESTS list

* open static_build flag

* remove distributed_fused_lamb_init from StaticBuildBlackList

* use initialized replacing IsInitialized

* recover codes

* delete useless codes

* close the flag
  • Loading branch information
AndSonder authored Sep 4, 2023
1 parent 201480d commit be9cb94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ std::set<std::string> StaticBuildBlackList = {
"cinn_launch" /*: to handle subgraph infermeta*/,
"run_program" /*: to handle scope output*/,
"sparse_sparse_coo_tensor" /*: to handle sparse output*/,
"shuffle_batch",
"shuffle_batch_grad",
"distributed_fused_lamb_init"};

namespace paddle {
Expand All @@ -60,8 +58,6 @@ bool BlockCanBeStaticBuilt(const framework::BlockDesc& block) {
// is_operator_base = (kernelCode >> 6) & 1
// is_custom_op = (kernelCode >> 5) & 1
// use_mkldnn = (kernelCode >> 4) & 1
// has_fluid_kernel = (kernelCode >> 3) & 1
// has_structed_kernel = (kernelCode >> 2) & 1
using KernelCode = int8_t;
std::set<std::pair<std::string, KernelCode>> invalid_ops;
for (auto& op : block.AllOps()) {
Expand All @@ -81,13 +77,11 @@ bool BlockCanBeStaticBuilt(const framework::BlockDesc& block) {
use_mkldnn = attr.index() == 1 ? PADDLE_GET_CONST(int, attr)
: PADDLE_GET_CONST(bool, attr);
}
bool has_fluid_kernel = OperatorWithKernel::AllOpKernels().count(op_type);
bool has_structured_kernel =
phi::KernelFactory::Instance().HasStructuredKernel(op_type);

KernelCode kernel_code = (in_black_list << 7) + (is_operator_base << 6) +
(is_custom_op << 5) + (use_mkldnn << 4) +
(has_fluid_kernel << 3) +
(has_structured_kernel << 2);
if (!OpsCanSkipedFakeAllocInStaticBuild.count(op_type)) {
if (in_black_list ||
Expand All @@ -107,8 +101,7 @@ bool BlockCanBeStaticBuilt(const framework::BlockDesc& block) {
<< ", is_operator_base = " << (item.second >> 6 & 1)
<< ", is_custom_op = " << (item.second >> 5 & 1)
<< ", use_mkldnn = " << (item.second >> 4 & 1)
<< ", has_fluid_kernel = " << (item.second >> 3 & 1)
<< ", has_structed_kerenl = " << (item.second >> 2 & 1) << "]\n";
<< (item.second >> 2 & 1) << "]\n";
}
VLOG(1) << ss.str();
}
Expand Down
1 change: 1 addition & 0 deletions test/legacy_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,7 @@ set(STATIC_BUILD_TESTS
test_fuse_bn_act_pass
test_fused_feedforward_op
test_fused_feedforward_pass
test_fused_layernorm_op
test_imperative_optimizer
test_lamb_op
test_layer_norm_op
Expand Down

0 comments on commit be9cb94

Please sign in to comment.