26 auto graph =
static_cast<Graph *
>(data);
31 auto remove_if_unused = [graph](
Operation *op) {
32 if (op->getType() == Operation::Type::input || op->getType() == Operation::Type::output)
36 std::all_of(op->getOutputs().cbegin(), op->getOutputs().cend(),
37 [](
const Operation::Output &output) { return output.getUses().empty(); });
41 graph->removeNode(op);
45 std::for_each(sorted_nodes.rbegin(), sorted_nodes.rend(), remove_if_unused);