mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00

* Add notes for tensors * Optimize some apis * move some warnings * Support build with Paddle2ONNX * Add protobuf support * Fix compile on mac * add clearn package script * Add paddle2onnx code * remove submodule * Add onnx ocde * remove softlink * add onnx code * fix error * Add cmake file * fix patchelf * update paddle2onnx * Delete .gitmodules --------- Co-authored-by: PaddleCI <paddle_ci@example.com> Co-authored-by: pangyoki <pangyoki@126.com> Co-authored-by: jiangjiajun <jiangjiajun@baidu.lcom>
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "onnxoptimizer/pass_manager.h"
|
|
|
|
namespace ONNX_NAMESPACE {
|
|
namespace optimization {
|
|
|
|
PassManager::PassManager() {}
|
|
PassManager::~PassManager() {}
|
|
|
|
GeneralPassManager::~GeneralPassManager() {
|
|
this->passes.clear();
|
|
}
|
|
void GeneralPassManager::add(std::shared_ptr<Pass> pass) {
|
|
this->passes.push_back(std::move(pass));
|
|
}
|
|
|
|
std::shared_ptr<PassManagerAnalysis> GeneralPassManager::run(Graph& graph) {
|
|
for (const std::shared_ptr<Pass>& pass : this->passes) {
|
|
auto pass_analysis = pass->runPass(graph);
|
|
}
|
|
return std::shared_ptr<PassManagerAnalysis>(new EmptyPassManagerAnalysis());
|
|
}
|
|
|
|
std::shared_ptr<PassManagerAnalysis> FixedPointPassManager::run(Graph& graph) {
|
|
bool fixed_point_optimization_done;
|
|
|
|
do {
|
|
fixed_point_optimization_done = false;
|
|
for (const std::shared_ptr<Pass>& pass : this->passes) {
|
|
std::shared_ptr<PostPassAnalysis> analysis = pass->runPass(graph);
|
|
if (pass->getPassAnalysisType() == PassAnalysisType::Empty) {
|
|
continue;
|
|
}
|
|
std::shared_ptr<CountBasedPassAnalysis> count_analysis =
|
|
std::static_pointer_cast<CountBasedPassAnalysis>(analysis);
|
|
|
|
while (count_analysis->fixedPointOptimizationNeeded()) {
|
|
count_analysis = std::static_pointer_cast<CountBasedPassAnalysis>(
|
|
pass->runPass(graph));
|
|
fixed_point_optimization_done = true;
|
|
}
|
|
}
|
|
} while (fixed_point_optimization_done);
|
|
|
|
return std::shared_ptr<PassManagerAnalysis>(new EmptyPassManagerAnalysis());
|
|
}
|
|
} // namespace optimization
|
|
} // namespace ONNX_NAMESPACE
|