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

index_add decomposed into index_put through TM Tensor

Open lorenzbc opened this issue 3 years ago • 6 comments

Combined all the commits from the index-add-to-put_TMTensor branch and moved it to a new branch that's rebased

lorenzbc avatar Jun 22 '22 22:06 lorenzbc

@ramiro050 and @pashu123 I moved it to a fresh branch and the CI went through!

lorenzbc avatar Jun 22 '22 22:06 lorenzbc

You can run the lit tests locally by doing cmake --build build --target check-torch-mlir

ramiro050 avatar Jun 22 '22 23:06 ramiro050

@ramiro050 not sure why but the actual python unit test is failing. What could cause a "failed to legalize operation 'torch.aten.index_add' that was explicitly marked illegal" error?

lorenzbc avatar Jun 24 '22 19:06 lorenzbc

@ramiro050 not sure why but the actual python unit test is failing. What could cause a "failed to legalize operation 'torch.aten.index_add' that was explicitly marked illegal" error?

That error means that your conversion pattern failed, so the op torch.aten.index_add stayed in the IR.

From the error message, you can tell that the input does have a rank, so the failure has to be in the getTensorRank(updates) != inputRank check. I think this is because the unit test is not right. In your unit test, the input has rank 3 and the source tensor has rank 2 according to the annotation.

ramiro050 avatar Jun 24 '22 19:06 ramiro050

The op is still marked as illegal despite the changes even though now the annotations match the types and shapes of the arguments

lorenzbc avatar Jun 27 '22 20:06 lorenzbc

The op is still marked as illegal despite the changes even though now the annotations match the types and shapes of the arguments

The test has inputs that are invalid in the decomposition. Here,

https://github.com/llvm/torch-mlir/blob/0c9084f7e14bb1479c7d20088d076b5eae3827a1/lib/Dialect/Torch/Transforms/DecomposeComplexOps.cpp#L1659

there is an expectation for the source tensor to have the same rank as the input tensor, but in your test the source tensor has rank 1, while the input tensor has rank 3

https://github.com/llvm/torch-mlir/blob/0c9084f7e14bb1479c7d20088d076b5eae3827a1/python/torch_mlir_e2e_test/test_suite/index_put.py#L830-L833

ramiro050 avatar Jun 27 '22 21:06 ramiro050

For the record, I plan to resurrect https://github.com/llvm/torch-mlir/pull/1063 since this effort / PR seems to be stale now. Please feel free to push back if that's not true..

sjain-stanford avatar Jan 26 '24 23:01 sjain-stanford

Yes, I think we can consider this stale, since there hasn't been an update in a year and a half.

ramiro050 avatar Jan 31 '24 00:01 ramiro050