Skip to content

Commit

Permalink
[XPU] Fix L3 autotune (#66323)
Browse files Browse the repository at this point in the history
* fix xpu l3 cache bug

* fix multi predictor

* fix multi predictor
  • Loading branch information
cmcamdy authored Aug 6, 2024
1 parent 1319992 commit 736a253
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,11 @@ bool AnalysisPredictor::ZeroCopyRun() {
config_.xpu_config_.l3_autotune_size,
place_);
}

if (config_.use_xpu_ && infer_xpu_ctx != nullptr &&
config_.xpu_config_.l3_autotune_size > 0) {
infer_xpu_ctx->L3CacheAutotune();
}
#endif

if (config_.new_executor_enabled()) {
Expand All @@ -2287,12 +2292,6 @@ bool AnalysisPredictor::ZeroCopyRun() {
}
inference::DisplayMemoryInfo(place_, "after run");

#ifdef PADDLE_WITH_XPU
if (config_.use_xpu_ && !config_.use_lite_ && infer_xpu_ctx != nullptr) {
infer_xpu_ctx->L3CacheAutotune();
}
#endif

// Fix TensorArray reuse not cleaned bug.
tensor_array_batch_cleaner_.CollectTensorArrays(sub_scope_);
tensor_array_batch_cleaner_.ResetTensorArray();
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/inference/api/infer_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void InferXPUContext::SetFcAutotuneInfo(std::string fc_autotune_file,
}

void InferXPUContext::L3CacheAutotune() {
if (l3_autotune_size_ == 0) return;
if (l3_autotune_size_ == 0 || l3_blocks_.size() == 0) return;
if (holder_map_.empty()) {
l3_plan_.RunAutotune(l3_blocks_, l3_size_);
auto* plan = l3_plan_.plan();
Expand Down Expand Up @@ -262,6 +262,7 @@ void InferXPUContext::L3CacheAutotune() {
}
}
}

#endif

} // namespace paddle

0 comments on commit 736a253

Please sign in to comment.