fix: 消除无效张量

Signed-off-by: YdrMaster <ydrml@hotmail.com>
This commit is contained in:
YdrMaster 2023-06-26 09:36:56 +08:00
parent 2f64997142
commit 1c84c3ebb9
1 changed files with 11 additions and 0 deletions

View File

@ -32,6 +32,17 @@ Tensor runWeightComputation(const Tensor &weight) {
Graph convertNCHWtoNHWCModel(Graph inG) {
// Construct new graph
// IT_ASSERT(inG->getInputs().size() == 1);
{
auto useless = vector<Tensor>();
for (const auto &t : inG->getTensors()) {
if (!t->getSource() && t->getTargets().empty()) {
useless.push_back(t);
}
}
for (auto t : useless) {
inG->removeTensor(t);
}
}
IT_ASSERT(inG->getOutputs().size() == 1);
bool status = inG->topo_sort();
IT_ASSERT(status);