metagraph-dev / mlir-graphblas

MLIR tools and dialect for GraphBLAS
https://mlir-graphblas.readthedocs.io/en/latest/
Apache License 2.0
15 stars 6 forks source link

Investigate using canonicalization passes to add graphblas.convert_layout ops when appropriate #152

Open paul-tqh-nguyen opened 3 years ago

paul-tqh-nguyen commented 3 years ago

Currently, in our lowering passes, we add graphblas.convert_layout ops when we're given a CSC matrix when the "real" lowering expects a CSR matrix.

It might be cleaner to use canonicalization passes passes to do this sort of thing.

It might also be a good idea to add tensor casts to convert fixed shaped tensors to tensors using ? in the shape. This would help with https://github.com/metagraph-dev/mlir-graphblas/issues/129.

For graphblas.comment ops, it's unclear whether or not these should be handled during lowering or canonicalization.

paul-tqh-nguyen commented 2 years ago

@jim22k and I came up with a plan to address this. I'll describe our proposed approach below.

We'll want to change the standard passes we use.

Implementation details (and misc. answers to misc. questions we had during our discussion):

CC @eriknw

paul-tqh-nguyen commented 2 years ago

After reading Dan Gohman's article on canonicalization (as recommended by MLIR), it turns out that there's no agreed upon strict clear line that differentiates optimization/transformation from canonicalization.

Since MLIR's canonicalization functionality is implemented as a pass, there's currently no impactful difference for us right now to implement any of the passes I've described above via canonicalization. Thus, I'm choosing to avoid using canonicalization at this time. If we decide to do so in the future, it'll be a trivial refactoring since canonicalization is implemented via rewrite patterns.