-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Conversion failure: tfl.batch_matmul "expected 3 but got 2" (regression since 2.14, worked in 2.13) #65769
Comments
hi @gustavla , I have replicated the issue and i got similar results. I am looking into the issue and will get back to you. |
Hi @gustavla, can you let us know what chip your mac is using? M series? Intel? Thanks for your help. |
@pkgoogle Apple silicon. Also repros on x86_64 Ubuntu. |
I was able to reproduce on x86_64 Debian on tf-nightly as well with the exact program above. One difference is I got this error/warning:
I attempted adding this line to see if it helps: converter.experimental_enable_resource_variables = True It did not help. @zichuan-wei, can you please take a look? Thanks. |
Hi @gustavla, if you are able to access a linux system you may be able to resolve your issue by using AI-Edge-Torch, you can find more information here: googleblog. I have actually created a simple script for converting your model here: import torch
import torch.nn as nn
import ai_edge_torch
class MyMatMul(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x0, x1):
x0_rank3 = torch.unsqueeze(x0, 1)
out = x0_rank3 @ x1
out = torch.squeeze(out, 1)
return out
input0_shape = (1, 5)
input1_shape = (1, 5, 7)
model = MyMatMul()
sample_inputs = (torch.randn(*input0_shape), torch.randn(*input1_shape))
edge_model = ai_edge_torch.convert(model.eval(), sample_inputs)
edge_model.export("my_mat_mul.tflite") If you want to, you can actually try visualizing the result in model-explorer as well. Please try them out and let us know if this resolves your issue. If you still need further help, feel free to open a new issue at the respective repo. |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. |
1. System information
pip install tensorflow-macos==2.16.1 tf-keras==2.16.0 keras==3.2.1
2. Code
3. Failure after conversion
The key is the final line:
error: 'tfl.batch_matmul' op found invalid output rank, expected 3 but got 2
.Note that the expand and squeeze are both required for the failure to reproduce.
4. Regression analysis
Replace tensorflow version in the pip installation above:
model.tflite
produced successfully)The above error happens across 2.14-2.16.
The text was updated successfully, but these errors were encountered: