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

Add some ops to static build list #55724

Closed
wants to merge 7 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,10 @@ void IrDependencyBuilder::ShrinkDownstreamMap() {
}

std::set<size_t> minumum_nexts;
for (size_t item : op_downstream_map_.at(i)) {
for (size_t item : op_downstream_map_->at(i)) {
bool not_after_any = true;
// find the op that is not executed after any
for (size_t other_item : op_downstream_map_.at(i)) {
for (size_t other_item : op_downstream_map_->at(i)) {
if (OpHappensBefore(other_item, item)) {
VLOG(8) << "happens_before: " << other_item << "->" << item
<< ", so skip " << item;
Expand All @@ -769,12 +769,12 @@ void IrDependencyBuilder::ShrinkDownstreamMap() {
}
// NOTE(Ruibiao): op_happens_before will not be changed when shrink
// dowstream map
op_downstream_map_.at(i) = minumum_nexts;
(*op_downstream_map_)[i] = minumum_nexts;
}
VLOG(8) << "Finish shrink downstream map";
VLOG(8) << "downstream count: " << CountDownstreamMap(op_downstream_map_);
VLOG(8) << "downstream count: " << CountDownstreamMap(*op_downstream_map_);
VLOG(8) << "downstream_map: " << std::endl
<< StringizeDownstreamMap(op_downstream_map_);
<< StringizeDownstreamMap(*op_downstream_map_);
}

void IrDependencyBuilder::AddDependencyForSequentialRun() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ class IrDependencyBuilder {

bool OpHappensBefore(size_t prior_op_idx, size_t posterior_op_idx) const {
PADDLE_ENFORCE_GE(
op_happens_before_.size(),
op_happens_before_->size(),
0,
phi::errors::Unavailable("op_happen_before is not yet built"));
return op_happens_before_.at(prior_op_idx).at(posterior_op_idx);
return op_happens_before_->at(prior_op_idx).at(posterior_op_idx);
}

void ShareDependencyFrom(DependencyBuilder* src);

private:
void AddDependencyForCoalesceTensorOp();
void AddDependencyForCommunicationOp();
Expand All @@ -140,13 +142,13 @@ class IrDependencyBuilder {
std::vector<std::vector<size_t>> ops_behind_;

// op_downstream_map_ is the mapping from op to its downstream-op set, that is
// to say, op_downstream_map_[i] == {a, b, c} means op[a], op[b] and op[c]
// to say, (*op_downstream_map_)[i] == {a, b, c} means op[a], op[b] and op[c]
// depend on op[i] directly.
std::map<size_t, std::set<size_t>> op_downstream_map_;
std::shared_ptr<std::map<size_t, std::set<size_t>>> op_downstream_map_;

// op_happens_before_ is a matrix form of ops_before_ and ops_behind_, it is
// used to speed up the query.
std::vector<std::vector<bool>> op_happens_before_;
std::shared_ptr<std::vector<std::vector<bool>>> op_happens_before_;
};

} // namespace interpreter
Expand Down
3 changes: 3 additions & 0 deletions paddle/fluid/framework/new_executor/program_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class ProgramInterpreter : public InterpreterBaseImpl {
// workqueue
std::shared_ptr<interpreter::AsyncWorkQueue> GetWorkQueue();

// op dependences
interpreter::DependencyBuilder* GetDependencyBuilder();

// scope
bool HasLocalScope() const;

Expand Down
17 changes: 17 additions & 0 deletions test/legacy_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1267,12 +1267,21 @@ set(STATIC_BUILD_TESTS
test_adagrad_op
test_adamw_op
test_arg_min_max_op
test_assign_pos_op
test_bincount_op
test_c_embedding_op
test_c_embedding_op_xpu
test_c_identity
test_c_split
test_decayed_adagrad_op
test_decoupled_py_reader
test_dgc_op
test_dgc_momentum_op
test_eig_op
test_eigh_op
test_fake_quantize_op
test_fetch_lod_tensor_array
test_ftrl_op
test_fused_attention_op
test_fused_attention_op_api
test_fuse_bn_act_pass
Expand All @@ -1281,14 +1290,18 @@ set(STATIC_BUILD_TESTS
test_imperative_optimizer
test_lamb_op
test_layer_norm_op
test_limit_by_capacity
test_lookup_table_bf16_op
test_lookup_table_v2_op
test_matmul_op
test_matmul_v2_op
test_merged_adam_op
test_momentum_op
test_nce
test_number_count_op
test_paddle_save_load_binary
test_prune_gate_by_capacity_op
test_random_routing_op
test_reduce_op
test_segment_ops
test_sparse_momentum_op
Expand All @@ -1311,6 +1324,10 @@ if(NOT WITH_GPU)
list(REMOVE_ITEM STATIC_BUILD_TESTS test_fused_feedforward_op_pass)
endif()

if(((NOT WITH_ROCM) AND (NOT WITH_GPU)) OR WIN32)
list(REMOVE_ITEM STATIC_BUILD_TESTS test_c_embedding_op)
endif()

foreach(STATIC_BUILD_TEST ${STATIC_BUILD_TESTS})
py_test_modules(
${STATIC_BUILD_TEST}_static_build MODULES ${STATIC_BUILD_TEST} ENVS
Expand Down
2 changes: 1 addition & 1 deletion third_party/mkldnn
Submodule mkldnn updated 2281 files