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>
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
// ATTENTION: The code in this file is highly EXPERIMENTAL.
|
|
// Adventurous users should note that the APIs will probably change.
|
|
|
|
#include "onnxoptimizer/optimize.h"
|
|
|
|
namespace ONNX_NAMESPACE {
|
|
namespace optimization {
|
|
|
|
GlobalPassRegistry Optimizer::passes;
|
|
|
|
Optimizer::Optimizer(
|
|
const std::vector<std::string>& names,
|
|
const bool fixed_point) {
|
|
if (fixed_point) {
|
|
this->pass_manager =
|
|
std::shared_ptr<FixedPointPassManager>(new FixedPointPassManager());
|
|
} else {
|
|
this->pass_manager =
|
|
std::shared_ptr<GeneralPassManager>(new GeneralPassManager());
|
|
}
|
|
for (const auto& name : names) {
|
|
auto pass = passes.find(name);
|
|
this->pass_manager->add(pass);
|
|
}
|
|
}
|
|
Optimizer::~Optimizer() {}
|
|
|
|
ModelProto Optimize(
|
|
const ModelProto& mp_in,
|
|
const std::vector<std::string>& names) {
|
|
Optimizer current_opt(names, false);
|
|
return current_opt.optimize(mp_in);
|
|
}
|
|
ModelProto OptimizeFixed(
|
|
const ModelProto& mp_in,
|
|
const std::vector<std::string>& names) {
|
|
Optimizer current_opt(names, true);
|
|
return current_opt.optimize(mp_in);
|
|
}
|
|
const std::vector<std::string> GetAvailablePasses() {
|
|
return Optimizer::passes.GetAvailablePasses();
|
|
}
|
|
const std::vector<std::string> GetFuseAndEliminationPass() {
|
|
return Optimizer::passes.GetFuseAndEliminationPass();
|
|
}
|
|
|
|
} // namespace optimization
|
|
} // namespace ONNX_NAMESPACE
|