Skip to content

Commit

Permalink
add fuse padding zero
Browse files Browse the repository at this point in the history
  • Loading branch information
qshuihu committed Nov 5, 2021
1 parent eb0a839 commit 4e577e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions paddle/fluid/operators/pull_box_sparse_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/operators/math/math_function.h"

DECLARE_bool(enable_pull_box_padding_zero);

namespace paddle {
namespace operators {

Expand Down Expand Up @@ -123,8 +125,10 @@ static void PullBoxSparseFunctor(const framework::ExecutionContext &ctx) {
const auto *slot = inputs[i];
auto *output = outputs[i];
if (slot->numel() == 0) {
// only support GPU
PaddingZeros<T>(ctx, output, batch_size, hidden_size);
if (FLAGS_enable_pull_box_padding_zero) {
// only support GPU
PaddingZeros<T>(ctx, output, batch_size, hidden_size);
}
continue;
}
output->mutable_data<T>(ctx.GetPlace());
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/platform/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,5 @@ DEFINE_bool(enable_pullpush_dedup_keys, false,
"enable pull push dedup keys, default false");
DEFINE_bool(enable_shuffle_by_searchid, false,
"enable dualbox shuffle by searchid, default false");
DEFINE_bool(enable_pull_box_padding_zero, true,
"enable pull box padding zero, default true");
1 change: 1 addition & 0 deletions python/paddle/fluid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def __bootstrap__():
'enable_slotrecord_reset_shrink',
'enable_pullpush_dedup_keys',
'enable_shuffle_by_searchid',
'enable_pull_box_padding_zero',
]
core.init_gflags(["--tryfromenv=" + ",".join(read_env_flags)])
core.init_glog(sys.argv[0])
Expand Down

0 comments on commit 4e577e7

Please sign in to comment.