MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::autodiff Namespace Reference

The automatic differentiation Plugin More...

Classes

class  AutoDiffEval
 This pass is the heart of AD. More...
 
class  AutoDiffZero
 Replaces calls to the zero axioms with actual zeros. More...
 
class  AutoDiffZeroCleanup
 Replaces remaining zeros (not resolvable) with ⊥. More...
 

Enumerations

%autodiff.ad_eval_pass
enum class  ad_eval_pass : flags_t
 
%autodiff.ad_zero_pass
enum class  ad_zero_pass : flags_t
 
%autodiff.ad_zero_cleanup_pass
enum class  ad_zero_cleanup_pass : flags_t
 
%autodiff.ad_ext_cleanup_pass
enum class  ad_ext_cleanup_pass : flags_t
 

Functions

void register_normalizers (Normalizers &normalizers)
 
Helpers
const Pipullback_type (const Def *E, const Def *A)
 computes pb type E* -> A* E - type of the expression (return type for a function) A - type of the argument (point of orientation resp.
 
const Defid_pullback (const Def *)
 
const Piautodiff_type_fun_pi (const Pi *)
 
const Defautodiff_type_fun (const Def *)
 

Variables

static constexpr plugin_t Plugin_Id = 0x9655014a1c70000
 

%autodiff.Tangent

enum class  Tangent : flags_t
 
const Deftangent_type_fun (const Def *)
 
Ref normalize_Tangent (Ref, Ref, Ref arg)
 

%autodiff.AD

enum class  AD : flags_t
 
enum class  ad : flags_t
 
Ref normalize_ad (Ref type, Ref callee, Ref arg)
 Currently this normalizer does nothin.
 
Ref normalize_AD (Ref type, Ref callee, Ref arg)
 

%autodiff.zero

enum class  zero : flags_t
 
const Defzero_def (const Def *T)
 
const Defzero_pullback (const Def *E, const Def *A)
 
Ref normalize_zero (Ref type, Ref callee, Ref arg)
 Currently this normalizer does nothing.
 

%autodiff.add

enum class  add : flags_t
 
Ref normalize_add (Ref type, Ref callee, Ref arg)
 Currently resolved the full addition.
 

%autodiff.sum

enum class  sum : flags_t
 
const Defop_sum (const Def *T, Defs)
 
Ref normalize_sum (Ref type, Ref callee, Ref arg)
 

Detailed Description

Enumeration Type Documentation

◆ AD

enum class mim::plug::autodiff::AD : flags_t
strong

Definition at line 22 of file autogen.h.

◆ ad

enum class mim::plug::autodiff::ad : flags_t
strong

Definition at line 30 of file autogen.h.

◆ ad_eval_pass

Definition at line 62 of file autogen.h.

◆ ad_ext_cleanup_pass

Definition at line 83 of file autogen.h.

◆ ad_zero_cleanup_pass

Definition at line 76 of file autogen.h.

◆ ad_zero_pass

Definition at line 69 of file autogen.h.

◆ add

enum class mim::plug::autodiff::add : flags_t
strong

Definition at line 46 of file autogen.h.

◆ sum

enum class mim::plug::autodiff::sum : flags_t
strong

Definition at line 54 of file autogen.h.

◆ Tangent

Definition at line 14 of file autogen.h.

◆ zero

enum class mim::plug::autodiff::zero : flags_t
strong

Definition at line 38 of file autogen.h.

Function Documentation

◆ autodiff_type_fun()

◆ autodiff_type_fun_pi()

const Pi * mim::plug::autodiff::autodiff_type_fun_pi ( const Pi * pi)

◆ id_pullback()

const Def * mim::plug::autodiff::id_pullback ( const Def * A)

Definition at line 32 of file autodiff.cpp.

References pullback_type(), and mim::Def::world().

Referenced by mim::plug::autodiff::AutoDiffEval::derive_().

◆ normalize_AD()

Ref mim::plug::autodiff::normalize_AD ( Ref type,
Ref callee,
Ref arg )

Definition at line 18 of file normalizers.cpp.

References autodiff_type_fun(), and mim::Def::world().

◆ normalize_ad()

Ref mim::plug::autodiff::normalize_ad ( Ref type,
Ref callee,
Ref arg )

Currently this normalizer does nothin.

TODO: Maybe we want to handle trivial lookup replacements here.

Definition at line 13 of file normalizers.cpp.

References mim::World::raw_app(), and mim::Def::world().

◆ normalize_add()

Ref mim::plug::autodiff::normalize_add ( Ref type,
Ref callee,
Ref arg )

Currently resolved the full addition.

There is no benefit in keeping additions around longer than necessary.

Definition at line 37 of file normalizers.cpp.

References mim::plug::core::add, mim::Lit::as(), mim::match(), mim::Def::projs(), mim::Idx::size(), and mim::Def::world().

◆ normalize_sum()

Ref mim::plug::autodiff::normalize_sum ( Ref type,
Ref callee,
Ref arg )

Definition at line 90 of file normalizers.cpp.

References mim::Def::projs(), and mim::Def::world().

◆ normalize_Tangent()

Ref mim::plug::autodiff::normalize_Tangent ( Ref ,
Ref ,
Ref arg )

Definition at line 25 of file normalizers.cpp.

References tangent_type_fun().

◆ normalize_zero()

Ref mim::plug::autodiff::normalize_zero ( Ref type,
Ref callee,
Ref arg )

Currently this normalizer does nothing.

We usually want to keep zeros as long as possible to avoid unnecessary allocations. A high-level addition with zero can be shortened directly.

Definition at line 30 of file normalizers.cpp.

References mim::World::raw_app(), and mim::Def::world().

◆ op_sum()

const Def * mim::plug::autodiff::op_sum ( const Def * T,
Defs defs )

Definition at line 169 of file autodiff.cpp.

References mim::World::app(), and mim::Def::world().

Referenced by mim::plug::autodiff::AutoDiffEval::augment_tuple().

◆ pullback_type()

const Pi * mim::plug::autodiff::pullback_type ( const Def * E,
const Def * A )

computes pb type E* -> A* E - type of the expression (return type for a function) A - type of the argument (point of orientation resp.

derivative - argument type for partial pullbacks)

Definition at line 62 of file autodiff.cpp.

References tangent_type_fun(), and mim::Def::world().

Referenced by mim::plug::autodiff::AutoDiffEval::augment_extract(), mim::plug::autodiff::AutoDiffEval::augment_lam(), mim::plug::autodiff::AutoDiffEval::augment_pack(), mim::plug::autodiff::AutoDiffEval::augment_tuple(), id_pullback(), and zero_pullback().

◆ register_normalizers()

void mim::plug::autodiff::register_normalizers ( Normalizers & normalizers)

Referenced by mim_get_plugin().

◆ tangent_type_fun()

const Def * mim::plug::autodiff::tangent_type_fun ( const Def * ty)

◆ zero_def()

const Def * mim::plug::autodiff::zero_def ( const Def * T)

Definition at line 140 of file autodiff.cpp.

References mim::Idx::size(), and mim::Def::world().

Referenced by mim::plug::autodiff::AutoDiffZero::rewrite().

◆ zero_pullback()

const Def * mim::plug::autodiff::zero_pullback ( const Def * E,
const Def * A )

Variable Documentation

◆ Plugin_Id

plugin_t mim::plug::autodiff::Plugin_Id = 0x9655014a1c70000
staticconstexpr

Definition at line 10 of file autogen.h.