mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-07 17:41:52 +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>
41 lines
1.3 KiB
C++
41 lines
1.3 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.
|
|
#pragma once
|
|
#include "onnxoptimizer/pass.h"
|
|
namespace ONNX_NAMESPACE {
|
|
namespace optimization {
|
|
struct EliminateDeadEnd final : public FullGraphBasedPass {
|
|
explicit EliminateDeadEnd()
|
|
: FullGraphBasedPass(PassType::Nop, PassEfficiency::Complete,
|
|
PassOptimizationType::Compute) {}
|
|
std::string getPassName() const override {
|
|
return "eliminate_deadend";
|
|
}
|
|
PassAnalysisType getPassAnalysisType() const override {
|
|
return PassAnalysisType::CountBased;
|
|
}
|
|
unsigned int EliminateDead(Graph& graph) {
|
|
unsigned int nodes_removed = 0;
|
|
auto nodes = graph.nodes().reverse();
|
|
for (auto it = nodes.begin(); it != nodes.end(); it++) {
|
|
auto node = *it;
|
|
if (!node->hasUses()) {
|
|
nodes_removed++;
|
|
it.destroyCurrent();
|
|
}
|
|
}
|
|
return nodes_removed;
|
|
}
|
|
std::shared_ptr<PostPassAnalysis> runPass(Graph& graph) override {
|
|
auto nodes_removed = this->EliminateDead(graph);
|
|
return std::shared_ptr<PostPassAnalysis>(
|
|
new CountBasedPassAnalysis(this, nodes_removed, false, false));
|
|
}
|
|
};
|
|
} // namespace optimization
|
|
} // namespace ONNX_NAMESPACE
|