Skip to content

Commit

Permalink
remove unused tensors from VK model's graph (#4427)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #4427

We implemented [operators fusion](#3769) (`conv+bn`) which fused `conv` and `bn`'s weights and biases, but the old parameters are not deleted. Hence we saw that VK model's size is nearly twice large as CPU's.

As regards mobilenet_v2, before this diff CPU vs VK: 14M vs 22M. After this diff, both of them have 14M.

Reviewed By: SS-JIA

Differential Revision: D60257047
  • Loading branch information
copyrightly authored and facebook-github-bot committed Jul 25, 2024
1 parent 889e5cb commit 9a5455d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backends/vulkan/serialization/vulkan_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ def get_or_create_value_for(self, arg: _Argument):
raise RuntimeError(f"Cannot create value for arg of type {type(arg)}")

def process_placeholder_node(self, node: Node) -> None:
# ignores any tensors that don't get used in any ops
if len(node.users) == 0:
return
ids = self.create_node_value(node)
if not self.is_param_node(node):
if isinstance(ids, int):
Expand Down

0 comments on commit 9a5455d

Please sign in to comment.