Skip to content

add support for automatic differentiation using Tapenade#3

Open
aerorohit wants to merge 1 commit intoadd_c_baackend_mainfrom
autodiff_tapenade_main
Open

add support for automatic differentiation using Tapenade#3
aerorohit wants to merge 1 commit intoadd_c_baackend_mainfrom
autodiff_tapenade_main

Conversation

@aerorohit
Copy link
Copy Markdown
Owner

Summary

  • Adds autodiff_tapenade.py integrating Tapenade as an automatic differentiation source
    transformation tool for Compyle-annotated functions.
  • Provides three user-facing classes:
    • ForwardGrad — forward-mode (tangent) differentiation
    • ReverseGrad — reverse-mode (adjoint) differentiation
    • ElementwiseGrad — differentiates elementwise kernels, with optional OpenMP parallelism
  • The pipeline: transpiles the annotated Python function to C via the c backend, invokes Tapenade to generate the derivative
    source, then compiles both together with pybind11 bindings via Cmodule.
  • Extends cimport.py with compile_tapenade_source and get_tpnd_obj_dir helpers for Tapenade-specific build steps.
  • Adds two examples: examples/autodiff/billiards.py (physics simulation) and examples/autodiff/nn_mnist.py (neural network
    on MNIST).

Test plan

  • tests/test_autodiff_tapenade.py — covers ForwardGrad, ReverseGrad, scalar/vector functions, and
    logistic regression gradients
  • tests/test_parallel.py — extended with ElementwiseGrad tests
  • Requires Tapenade installed; tests should be skipped gracefully if not present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant