Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 'replace the usage of keys of self.io_module ' #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions mqbench/custom_quantizer/academic_quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def module_type_to_quant_input(self) -> tuple:
) + self.additional_module_type

def _get_post_act_8bit_node_name(self, model):
for node in self.io_module.values():
for _arg in node.args:
if isinstance(_arg, torch.fx.node.Node):
self.post_act_8bit_node_name.append(_arg.name)
for nodes in self.io_module.values():
for node in nodes:
for _arg in node.args:
if isinstance(_arg, torch.fx.node.Node):
self.post_act_8bit_node_name.append(_arg.name)

def _get_io_module(self, model):
total_args = []
Expand All @@ -77,11 +78,22 @@ def _get_io_module(self, model):
the_first_layer = True
total_args.append(_arg.name)
if the_first_layer:
self.io_module[node.target] = node
if node.target in self.io_module.keys():
# 如果已经创建过键值对了的话,列表中添加新的相关node
self.io_module[node.target].append(node)
else:
# 如果还没有创建键值对,则定义键值对
self.io_module[node.target] = [node]
if node.op == 'output':
for _arg in node.args:
if isinstance(_arg, torch.fx.node.Node):
self.io_module[_arg.target] = _arg
if _arg.target in self.io_module.keys():
# 如果已经创建过键值对了的话,列表中添加新的相关node
self.io_module[_arg.target].append(_arg)
else:
# 如果还没有创建键值对,则定义键值对
self.io_module[_arg.target] = [_arg]

def _find_act_quants(self, model: GraphModule) -> List:
nodes = list(model.graph.nodes)
Expand Down