zugexiaodui / torch_flops

A library for calculating the FLOPs in the forward() process based on torch.fx
MIT License
73 stars 2 forks source link

遇到报错:AttributeError: 'tuple' object has no attribute '__name__' #16

Open hyc9 opened 4 weeks ago

hyc9 commented 4 weeks ago

感谢你的工作!当我使用时,我遇到了这样的报错: AttributeError: 'tuple' object has no attribute 'name'. Did you mean: 'ne'?

它在flops_engine.py, line 420触发: node_module_name = next(reversed(node.meta[_var_name].values())).name

我还没有明白错误发生的原因,您对这个问题了解吗?如果需要进一步信息请告知,非常感谢!

Zn-H commented 2 weeks ago

next(reversed(node.meta[_var_name].values()))返回的是一个元组,不具有.name属性,我输出内容后发现它是一个描述层级的元组,将.name改为[0]访问第一个描述层级名称的元素之后可以正常运作。 希望对你有帮助