You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Thrsu (via GitHub)" <gi...@apache.org> on 2023/09/15 14:39:19 UTC

[GitHub] [tvm] Thrsu opened a new issue, #15758: [Bug] [Unity] KeyError: "None" when converting torch.fx model to TVM with layer_norm operation

Thrsu opened a new issue, #15758:
URL: https://github.com/apache/tvm/issues/15758

   I encountered a KeyError while trying to convert a Torch FX model with a layer normalization operation to TVM using the from_fx function from the tvm.relax.frontend.torch module.
   
   ### Actual behavior
   
   ```
   Traceback (most recent call last):
     ...
       mod = from_fx(fx_model, input_info)
     File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/torch/fx_translator.py", line 1468, in from_fx
       return TorchFXImporter().from_fx(
     File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/torch/fx_translator.py", line 1355, in from_fx
       self.env[node] = self.convert_map[func_name](node)
     File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/torch/fx_translator.py", line 877, in _layer_norm
       gamma = self.env[node.kwargs["weight"]]
   KeyError: None
   ```
   ### Environment
   
   - branch: unity
   - tvm: v0.14.dev0-595-gfa0d35b
   - torch: 2.0.1
   
   ### Steps to reproduce
   
   ```python
   import torch
   from torch import fx
   from torch.nn import Module
   import tvm
   from tvm import relax
   from tvm.relax.frontend.torch import from_fx
   
   input_data = torch.randn([4, 2, 2, 5], dtype=torch.float32)
   para_1 = (2, 2, 5)
   para_2 = None
   para_3 = None
   para_4 = 0.001
   class layer_norm(Module):
       def forward(self, input):
           return torch.nn.functional.layer_norm(input, para_1,para_2,para_3,para_4,)
   model = layer_norm().float()
   input_info = list(zip([list(inp.shape) for inp in input_data], [str(inp.dtype) for inp in input_data]))
   fx_model : torch.fx.GraphModule = fx.symbolic_trace(model)
   with torch.no_grad():
       mod = from_fx(fx_model, input_info)
   ```
   ### Triage
   
   * needs-triage
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [Unity] KeyError: "None" when converting torch.fx model to TVM with layer_norm operation [tvm]

Posted by "Thrsu (via GitHub)" <gi...@apache.org>.
Thrsu closed issue #15758: [Bug] [Unity] KeyError: "None" when converting torch.fx model to TVM with layer_norm operation
URL: https://github.com/apache/tvm/issues/15758


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org