mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +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>
32 lines
763 B
C++
32 lines
763 B
C++
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <onnxoptimizer/optimize.h>
|
|
|
|
#include <onnx/checker.h>
|
|
#include <onnx/onnx_pb.h>
|
|
|
|
#include <fstream>
|
|
|
|
int main(int argc, char **argv) {
|
|
ONNX_NAMESPACE::ModelProto model;
|
|
std::ifstream ifs(argv[1]);
|
|
bool success = model.ParseFromIstream(&ifs);
|
|
if (!success) {
|
|
std::cout << "load failed" << std::endl;
|
|
return -1;
|
|
}
|
|
onnx::checker::check_model(model);
|
|
const auto new_model = onnx::optimization::Optimize(
|
|
model, onnx::optimization::GetFuseAndEliminationPass());
|
|
onnx::checker::check_model(new_model);
|
|
std::ofstream ofs(argv[2]);
|
|
success = new_model.SerializePartialToOstream(&ofs);
|
|
if (!success) {
|
|
std::cout << "save failed" << std::endl;
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|