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 has_structed_kerenl and has_fluid_kernel #56779

Merged
merged 11 commits into from
Sep 4, 2023
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