Skip to content

Commit

Permalink
[hpc infer] fix bench perf number
Browse files Browse the repository at this point in the history
Reviewed By: yinghai, jianyuh

Differential Revision: D31505288

fbshipit-source-id: e4951a7c5813e0ee38903dec4cef61531f1b4059
  • Loading branch information
842974287 authored and facebook-github-bot committed Oct 9, 2021
1 parent 904fbad commit e5f6f35
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions torch/fx/experimental/const_fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def __init__(
const_subgraph: Optional[torch.fx.Graph] = None,
fx_const_folded_attrs_name: str = None,
):
# In init, we set graph's owning module to root which will make graph's
# owning module be None because graph already have a owning module. We
# need owning module to run DCE. To work around we set the number of
# graph's owners to 0.
graph._owners = 0
super().__init__(root, graph)
self.const_subgraph_module = (
None
Expand Down Expand Up @@ -152,14 +157,6 @@ def mod_partition(node: torch.fx.Node):
const_gm, non_const_gm = split.submod_0, split.submod_1
const_mod_name, non_const_mod_name = "submod_0", "submod_1"

# Later we are creating get_attr nodes from main module get_attr nodes and we use the
# same node.target. If there's a get_attr that refers to an attributes in a module and
# this module is not included in non_const_gm then we would have a trouble when creating
# get_attr ndoes because it will try to find the module that owns the attribute first.
# Setting owning_module here makes the owning_module of non_const_gm.graph to None then
# the check when creating get_attr nodes will get skipped.
non_const_gm.graph.owning_module = split

# The module that a call_module node refers to gets copied to submodules during split.
# The path to the module also gets inlined, i.e. mod.a.b -> mod_a_b. Here we need to
# attach inlined modules to `split` as it's the owning module now.
Expand Down

0 comments on commit e5f6f35

Please sign in to comment.