Volume of affine polytope calculation

Hi,
I’m looking to calculate the exact volume of an affine polytope defined by a bunch of AffineFor / AffineIf and AffineApply ops. There doesn’t seem to be such a function in FlatAffineConstraints. Is there a plan to add such a function (or am i missing something) ?
Thanks

The general problem of counting integer points in a polytope is a complex topic in itself and there are entire libraries for this purpose like barvinok: Public Git Hosting - barvinok.git/summary.
I don’t think there is any plan to add such a function in MLIR (it’d really be a library and not a mere function) — I haven’t heard of any at least. Although such a function could have many use cases for analysis, it’s an expensive operation depending on exactness and generality for even small-sized programs as far as compilation use cases go. Interfacing an external library like barvinok in a downstream repo would perhaps be a good experimental approach that is the fastest one to boot with. Restricted cases like hyper-rectangular sets are far simpler to handle but can still involve significant complexity depending on min/max/conditionals and unions.

Okay thanks for letting me know!

Incidentally, this is relevant: ⚙ D119228 [MLIR][Presburger] Support computing volumes via hyperrectangular overapproximation

3 Likes