-
Notifications
You must be signed in to change notification settings - Fork 157
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
Introduce LayerNorm IR ? #14447
Comments
@Samsung/one_compiler , @Samsung/one_onert , comments ? |
At least for this year, we haven't need LayerNorm. Instead, RMSNorm was used in our target model. Thus, it is low priority at this moment in runtime perspective. However, if it is necessary for front-end or some model I am not aware of. Please feel free to add. |
@seanshpark Could you check if the parameter of layernorm in your example code matches with the real model? If LN is given as a single Op, our backend device may convert it to InstanceNorm. For example, Before After I'm not against introducing LN (maybe for backends other than npu), but for now it would be also possible to just use InstanceNorm. |
got same attribute with this import onnx
import torch
import torch.nn as nn
class LayerNormNet(nn.Module):
def __init__(self):
super().__init__()
self.ln = nn.LayerNorm((128))
def forward(self, x):
out = self.ln(x)
return out
net = LayerNormNet()
inp = torch.randn(1, 16384, 128)
torch.onnx.export(net, inp, "ln11.onnx", opset_version=11)
onnx.shape_inference.infer_shapes_path('ln11.onnx', 'ln11-si.onnx')
torch.onnx.export(net, inp, "ln17.onnx", opset_version=17)
onnx.shape_inference.infer_shapes_path('ln17.onnx', 'ln17-si.onnx') |
I expected this :) |
Introducing LN may lead to a lot of works to do (including npu compiler) but no visible benefit as of now. If |
If I understand this correctly, in anyway around, or (1) ONNX model has something like this? Add;
|
Yes. I imagined the first approach which does not need modification on circle schema.
Even if onnx model has decomposed LN (due to low opset version), the fusion can be done inside Please note that it's just my opinion to minimize our workload considering the current generation of npu. For the next generation npu, we may need further discussion. |
As there is no particular benefit adding |
Transformers(including ViT) has
LayerNorm
Op in the graph.Circle model from ONNX has decomposed sub graph but would it be better to process as a single Node ?
test code to generate onnx
onnx graph
The text was updated successfully, but these errors were encountered: