``Node`` represents the variables (Tensor/Module/other python object) used in Module's forward method. They are inputs/outputs of Expr(the operations on variables).
param expr: the Expr which produces the node
param name: the name of the node
"""
expr=None
__total_id=0
_id=None
_name=None
def__init__(self,expr:"Expr",name:str=None):
self.expr=expr
self._id=Node.__total_id
Node.__total_id+=1
self._name=name
def__repr__(self):
ifself._nameisNone:
return"%{}".format(self._id)
else:
return"%{}".format(self._name)
classModuleNode(Node):
"""
``ModuleNode`` represents the Module objects.
Attributes:
module_type: type of the Module correspending to the ModuleNode
graph: the InternalGraph which will be interpreted when call Module's forward method
attr_type_map: record the type of Module's attributes