TY - JOUR
T1 - Aδ
T2 - Autodiff for Discontinuous Programs - Applied to Shaders
AU - Yang, Yuting
AU - Barnes, Connelly
AU - Adams, Andrew
AU - Finkelstein, Adam
N1 - Publisher Copyright:
© 2022 Owner/Author.
PY - 2022/7/22
Y1 - 2022/7/22
N2 - Over the last decade, automatic differentiation (AD) has profoundly impacted graphics and vision applications - - both broadly via deep learning and specifically for inverse rendering. Traditional AD methods ignore gradients at discontinuities, instead treating functions as continuous. Rendering algorithms intrinsically rely on discontinuities, crucial at object silhouettes and in general for any branching operation. Researchers have proposed fully-automatic differentiation approaches for handling discontinuities by restricting to affine functions, or semi-automatic processes restricted either to invertible functions or to specialized applications like vector graphics. This paper describes a compiler-based approach to extend reverse mode AD so as to accept arbitrary programs involving discontinuities. Our novel gradient rules generalize differentiation to work correctly, assuming there is a single discontinuity in a local neighborhood, by approximating the prefiltered gradient over a box kernel oriented along a 1D sampling axis. We describe when such approximation rules are first-order correct, and show that this correctness criterion applies to a relatively broad class of functions. Moreover, we show that the method is effective in practice for arbitrary programs, including features for which we cannot prove correctness. We evaluate this approach on procedural shader programs, where the task is to optimize unknown parameters in order to match a target image, and our method outperforms baselines in terms of both convergence and efficiency. Our compiler outputs gradient programs in TensorFlow, PyTorch (for quick prototypes) and Halide with an optional auto-scheduler (for efficiency). The compiler also outputs GLSL that renders the target image, allowing users to interactively modify and animate the shader, which would otherwise be cumbersome in other representations such as triangle meshes or vector art.
AB - Over the last decade, automatic differentiation (AD) has profoundly impacted graphics and vision applications - - both broadly via deep learning and specifically for inverse rendering. Traditional AD methods ignore gradients at discontinuities, instead treating functions as continuous. Rendering algorithms intrinsically rely on discontinuities, crucial at object silhouettes and in general for any branching operation. Researchers have proposed fully-automatic differentiation approaches for handling discontinuities by restricting to affine functions, or semi-automatic processes restricted either to invertible functions or to specialized applications like vector graphics. This paper describes a compiler-based approach to extend reverse mode AD so as to accept arbitrary programs involving discontinuities. Our novel gradient rules generalize differentiation to work correctly, assuming there is a single discontinuity in a local neighborhood, by approximating the prefiltered gradient over a box kernel oriented along a 1D sampling axis. We describe when such approximation rules are first-order correct, and show that this correctness criterion applies to a relatively broad class of functions. Moreover, we show that the method is effective in practice for arbitrary programs, including features for which we cannot prove correctness. We evaluate this approach on procedural shader programs, where the task is to optimize unknown parameters in order to match a target image, and our method outperforms baselines in terms of both convergence and efficiency. Our compiler outputs gradient programs in TensorFlow, PyTorch (for quick prototypes) and Halide with an optional auto-scheduler (for efficiency). The compiler also outputs GLSL that renders the target image, allowing users to interactively modify and animate the shader, which would otherwise be cumbersome in other representations such as triangle meshes or vector art.
KW - automatic differentiation
KW - differentiable programming
KW - differentiable rendering
KW - domain-specific language
UR - http://www.scopus.com/inward/record.url?scp=85137723761&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=85137723761&partnerID=8YFLogxK
U2 - 10.1145/3528223.3530125
DO - 10.1145/3528223.3530125
M3 - Article
AN - SCOPUS:85137723761
SN - 0730-0301
VL - 41
JO - ACM Transactions on Computer Systems
JF - ACM Transactions on Computer Systems
IS - 4
M1 - 3530125
ER -