in optimum/onnxruntime/preprocessors/passes/excluders.py [0:0]
def __call__(self, _: ModelProto, model: OnnxModel) -> Tuple[Set[str], Set[str]]:
# Find out the nodes to exclude in the graph
candidate_nodes_to_exclude = {
candidate_output: candidate.name
for candidate in model.get_nodes_by_op_type(self.operator_type_to_exclude)
for candidate_output in candidate.output
}
nodes_of_following_type = {
node_input: node.name
for node in model.get_nodes_by_op_type(self.following_operator_type)
for node_input in node.input
}
# Intersection of both are the one we want to remove
to_exclude = set(candidate_nodes_to_exclude.keys()).intersection(nodes_of_following_type.keys())
nodes_to_exclude = {candidate_nodes_to_exclude[node] for node in to_exclude}
return set(), nodes_to_exclude