-
Notifications
You must be signed in to change notification settings - Fork 634
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
Potentially wrong number of argument in cumsum op #2303
Comments
Right now the torch version coremltools officially supports is |
@jakesabathia2 From what I can tell this issue persists over all versions of pytorch from at least 2.0, as the signature of the torch.cumsum has not changed since. Can You suggest why this would work with older version of PyTorch? |
The third argument is optional. It is treated as optional in torch.onnx: and you guys actually not use the third argument here - you ignore it coremltools/coremltools/converters/mil/frontend/torch/ops.py Lines 929 to 936 in 8b7048e
|
As an update I upload the code that generates the issue. Below are all version of libraries:
and the actual code import torch
from torch.export import export
from executorch.exir import to_edge
from torch import nn
import coremltools as ct
class TestCumsum(nn.Module):
"""
Test class
"""
def __init__(self) -> None:
super().__init__()
def forward(self) -> torch.Tensor:
"""Test forward"""
h, w = 100, 100
grid = torch.ones([h, w], device="cpu", dtype=torch.float32)
_y_embed = grid.cumsum(dim=0)
x_embed = grid.cumsum(dim=1)
return x_embed
if __name__ == "__main__":
example_args = tuple([])
aten_dialect = export(TestCumsum(), example_args)
edge_dialect = to_edge(aten_dialect).exported_program()
mlmodel = ct.convert(edge_dialect) |
Locally confirmed fix with the (slightly modified) reproduce with torch 2.4
Will include this fix in next release |
Great! Thank you much for your help 😁 |
I discovered that the expected number of arguments to
cumsum
op in coremltools might be wrong while exporting PyTorch module to *.pte file (executorch). Seecoremltools/coremltools/converters/mil/frontend/torch/ops.py
Line 931 in 8b7048e
cumsum
op expects 3 arguments while only 2 were provided. Changing this value to 2 fixed suppressed the error.To Reproduce
System environment (please complete the following information):
Additional context
Discovered this while exporting Pytorch model to executorch with CoreML backend.
The text was updated successfully, but these errors were encountered: