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

Adding shape information for Torch MLIR LTC Backend #727

Closed
henrytwo opened this issue Apr 1, 2022 · 4 comments
Closed

Adding shape information for Torch MLIR LTC Backend #727

henrytwo opened this issue Apr 1, 2022 · 4 comments

Comments

@henrytwo
Copy link
Member

henrytwo commented Apr 1, 2022

After #725 lands, the next goal is to try to add shape information to the output MLIR.

lazy::Node contains tensor shape information (retrieved by calling shapes()); however, this information is not retained when it's converted to a jit::Node. (This shows that the only thing extracted from the lazy::Node during lowering is its symbol)

It also looks like there is nothing on the MLIR generation side for adding shape information (as far as I could see).

I don't think there is anything on the JIT side that enables storing tensor shape information, which might make this more difficult. My immediate thought is to try to map lazy::Node -> MlirOperation to insert shape information, but that doesn't feel like the most proper way to do this.

@silvasean, do you have any thoughts or ideas on how to proceed with this?

cc: @antoniojkim @ke1337

@silvasean
Copy link
Contributor

silvasean commented Apr 1, 2022

c10::TensorType seems to support having a shape specified, so any jit::Value's of TensorType should be able to hold a shape. I think the path forward here is for upstream to create the jit::Value's with more precise TensorType's.

@henrytwo
Copy link
Member Author

henrytwo commented Apr 1, 2022

Ah that's good to hear -- I'll investigate what we can do upstream

@henrytwo
Copy link
Member Author

henrytwo commented Apr 4, 2022

I opened an issue on the PyTorch side here: pytorch/pytorch#75217. Through some testing it seems like on the torch-mlir side we already generate MLIR with the correct shape information, which is nice to see.

@henrytwo
Copy link
Member Author

henrytwo commented Apr 7, 2022

Closing this issue now that we have a PR open: #742

@henrytwo henrytwo closed this as completed Apr 7, 2022
qedawkins pushed a commit to nod-ai/torch-mlir that referenced this issue Oct 3, 2022
* Reorganize main function.

* Follow review comments.

* Emit constants are globals in Krnl and LLVM dialects.

* Add inference for Range operation.

* Add lowering to Krnl for f32.

* Add range lowering.

* Fix comment.

* Add Range op lowering for all supported types.

* Add backend tests.

* Fix memref access.

* Fix inference test.
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

2 participants