Skip to content
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

failed to legalize operation 'torch.aten.cumsum' #3866

Open
DavidGinten opened this issue Nov 12, 2024 · 0 comments
Open

failed to legalize operation 'torch.aten.cumsum' #3866

DavidGinten opened this issue Nov 12, 2024 · 0 comments

Comments

@DavidGinten
Copy link

Hello,

I encountered the following error when trying to run this model with IREE Turbine: https://huggingface.co/facebook/detr-resnet-50
The error does not occur in IREE Turbine though but in the lowering from the torch aten cumsum operation to TMTensor.

Error:

Failure while executing pass pipeline (pm.run()): failed to legalize operation 'torch.aten.cumsum' that was explicitly marked illegal.

The problem seems to occur in here:

if (!matchPattern(op.getDim(), m_TorchConstantInt(&dim)))
return rewriter.notifyMatchFailure(
op, "unimplemented: only constant dim value is supported");

To reproduce:

import torch
import numpy as np
from transformers import AutoModelForObjectDetection
from iree.turbine import aot
from iree.compiler.ir import Context
from iree.compiler.passmanager import PassManager

model = AutoModelForObjectDetection.from_pretrained("facebook/detr-resnet-50")

model.eval()

args = ((np.random.randn(1, 3, 224, 224).astype(np.float32),))
args_torch = tuple([torch.from_numpy(x) for x in args])

exported_model: aot.ExportOutput = aot.export(
            model, args=args_torch, dynamic_shapes=None, strict_export=False
        )

context: Context = exported_model.mlir_module.context
with context:
    pm = PassManager.parse("builtin.module(torch-to-iree)")
    pm.run(exported_model.mlir_module.operation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant