class_docstr: This class is used to construct the restructure computation graph for
  call_module node with bias addition inside.
class_docstr_tok: ["This","class","is","used","to","construct","the","restructure","computation","graph","for","call_module","node","with","bias","addition","inside","."]
docstr: This method is used to construct the whole restructure computation graph for call_module node with bias
  addition inside.
  
  A whole restructure computation graph will contain a weight node, a bias node, a non-bias addition computation node,
  a bias reshape node if needed and a bias addition node.
  
  Use Conv2d module as an example:
  The origin node is:
      %conv: call_module[target=conv](args = (%x,), kwargs = {})
  Restructured graph is:
      %conv_weight : [#users=1] = get_attr[target=conv.weight]
      %conv_bias : [#users=1] = get_attr[target=conv.bias]
      %conv2d : [#users=1] = call_function[target=torch.conv2d](args = (%x, %conv_weight), kwargs = {})
      %view : [#users=1] = call_method[target=view](args = (%conv_bias, [1, -1, 1, 1]), kwargs = {})
      %add : [#users=1] = call_function[target=operator.add](args = (%conv2d, %view), kwargs = {})
docstr_tok: ["This","method","is","used","to","construct","the","whole","restructure","computation","graph","for","call_module","node","with","bias","addition","inside",".","A","whole","restructure","computation","graph","will","contain","a","weight","node",",","a","bias","node",",","a","non-bias","addition","computation","node",",","a","bias","reshape","node","if","needed","and","a","bias","addition","node",".","Use","Conv2d","module","as","an","example",":","The","origin","node","is",":","%","conv",":","call_module","[","target=conv","]","(","args","=","(","%","x",",",")",",","kwargs","=","{","}",")","Restructured","graph","is",":","%","conv_weight",":","[","#","users=1","]","=","get_attr","[","target=conv.weight","]","%","conv_bias",":","[","#","users=1","]","=","get_attr","[","target=conv.bias","]","%","conv2d",":","[","#","users=1","]","=","call_function","[","target=torch.conv2d","]","(","args","=","(","%","x",",","%","conv_weight",")",",","kwargs","=","{","}",")","%","view",":","[","#","users=1","]","=","call_method","[","target=view","]","(","args","=","(","%","conv_bias",",","[","1",",","-1",",","1",",","1","]",")",",","kwargs","=","{","}",")","%","add",":","[","#","users=1","]","=","call_function","[","target=operator.add","]","(","args","=","(","%","conv2d",",","%","view",")",",","kwargs","=","{","}",")"]
code: def generate(self):
      """
      This method is used to construct the whole restructure computation graph for call_module node with bias
      addition inside.
  
      A whole restructure computation graph will contain a weight node, a bias node, a non-bias addition computation node,
      a bias reshape node if needed and a bias addition node.
  
      Use Conv2d module as an example:
      The origin node is:
          %conv: call_module[target=conv](args = (%x,), kwargs = {})
      Restructured graph is:
          %conv_weight : [#users=1] = get_attr[target=conv.weight]
          %conv_bias : [#users=1] = get_attr[target=conv.bias]
          %conv2d : [#users=1] = call_function[target=torch.conv2d](args = (%x, %conv_weight), kwargs = {})
          %view : [#users=1] = call_method[target=view](args = (%conv_bias, [1, -1, 1, 1]), kwargs = {})
          %add : [#users=1] = call_function[target=operator.add](args = (%conv2d, %view), kwargs = {})
      """
  
file_path: ColossalAI/colossalai/fx/tracer/bias_addition_patch/patched_bias_addition_module/bias_addition_module.py
imports: import operator
  from abc import ABC, abstractmethod
  import torch
  import torch.nn.functional
label_desc: Use image node_id 7 for calling the BiasAdditionModule obj's underlying member method code with example usage: obj.generate() without return types