bayesiains / nflows

Normalizing flows in PyTorch
MIT License
845 stars 118 forks source link

Fix In-place Assignments for `PiecewiseRationalQuadratic` Compatibility with `functorch` and `torch2.0` #77

Open HamidrezaKmK opened 1 year ago

HamidrezaKmK commented 1 year ago

Hello,

While working on my project (OOD Detection using Manifolds), I noticed an issue with the current implementation of the PiecewiseRationalQuadratic coupling layers. The in-place masked assignments, specifically:

outputs[outside_interval_mask] = inputs[outside_interval_mask]

pose challenges when constructing the computation graph in both functorch and torch2.0.

To address this, I've made necessary modifications in my fork, ensuring a functional adaptation that aligns with these libraries without altering the primary functionality of the layer.

I kindly ask for your review of these changes. If they align with your vision and maintain the library's integrity, I'd appreciate their incorporation into the main branch.

Thank you for your time and consideration.

Best, Hamid