Skip to content

Commit

Permalink
remove unused tensors from VK model's graph
Browse files Browse the repository at this point in the history
Summary:
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.

Differential Revision: D60257047
  • Loading branch information
copyrightly authored and facebook-github-bot committed Jul 25, 2024
1 parent 77c905d commit c5d02e3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions backends/vulkan/serialization/vulkan_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,14 @@ 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:
ids = self.create_node_value(node)
if not self.is_param_node(node):
if isinstance(ids, int):
self.input_ids.append(ids)
else:
self.input_ids += ids
# ignores any tensors that don't get used in any ops
if len(node.users) != 0:
ids = self.create_node_value(node)
if not self.is_param_node(node):
if isinstance(ids, int):
self.input_ids.append(ids)
else:
self.input_ids += ids

def process_getitem_node(self, node: Node) -> None:
# Find ValueList id from the collection node.
Expand Down

0 comments on commit c5d02e3

Please sign in to comment.