torch-mlir icon indicating copy to clipboard operation
torch-mlir copied to clipboard

LSTM supporting

Open MissyDu opened this issue 2 years ago • 5 comments

When we convert a model containing LSTM op to torch-mlir, this op is converted to be "torch.operator "aten.lstm.data"".

Do you have any plan to support LSTM operation in Torch_Op? If not, would you like to give me a guide that i can do it by myself? Or, whether "torch.operator" is okay for further pass and other processsing?

MissyDu avatar Jun 09 '22 02:06 MissyDu

I would recommend that we decompose the op -- @vivekkhandelwal1 do you know if there is a decomposition in functorch for this?

silvasean avatar Jun 09 '22 17:06 silvasean

Hi @silvasean, I don't think that the decomposition for this op exists in functorch.

vivekkhandelwal1 avatar Jun 10 '22 14:06 vivekkhandelwal1

@vivekkhandelwal1 -- can you point MissyDu how to add the decomposition?

silvasean avatar Jun 13 '22 19:06 silvasean

Hi @MissyDu, the decomposition has now moved to the PyTorch core from functorch. You can also add the decomposition for the LSTM op directly in the PyTorch core. Please follow this PR (https://github.com/pytorch/pytorch/pull/79001) to know how to add the decomposition.

vivekkhandelwal1 avatar Jun 14 '22 03:06 vivekkhandelwal1

@vivekkhandelwal1 @silvasean, thank you so much for you quick and nice answers! I also think decomposition solution is better than to define a LSTM op for backend. I will try decomposition according to your above guide. Besides, I have tried to register a LSTM op according to(PR888) and it works well for now. Thank you again for great work!

MissyDu avatar Jun 14 '22 07:06 MissyDu

It looks like this was resolved to use a decomposition.

silvasean avatar Oct 07 '22 14:10 silvasean

@vivekkhandelwal1 @silvasean, thank you so much for you quick and nice answers! I also think decomposition solution is better than to define a LSTM op for backend. I will try decomposition according to your above guide. Besides, I have tried to register a LSTM op according to(PR888) and it works well for now. Thank you again for great work!

can you please give a hint how did you registered LSTM? I'm kinda lost in this code and LSTM conversion still doesn't work in torch_mlir

JBloodless avatar Sep 27 '23 16:09 JBloodless