Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::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  ad_eval_pass : flags_t
 
%autodiff.ad_zero_pass
enum  ad_zero_pass : flags_t
 
%autodiff.ad_zero_cleanup_pass
enum  ad_zero_cleanup_pass : flags_t
 
%autodiff.ad_ext_cleanup_pass
enum  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  Tangent : flags_t
 
const Deftangent_type_fun (const Def *)
 
Ref normalize_Tangent (Ref, Ref, Ref arg)
 

%autodiff.AD

enum  AD : flags_t
 
enum  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  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  add : flags_t
 
Ref normalize_add (Ref type, Ref callee, Ref arg)
 Currently resolved the full addition.
 

%autodiff.sum

enum  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

Definition at line 27 of file autogen.h.

◆ ad

Definition at line 39 of file autogen.h.

◆ ad_eval_pass

Definition at line 87 of file autogen.h.

◆ ad_ext_cleanup_pass

◆ ad_zero_cleanup_pass

◆ ad_zero_pass

Definition at line 98 of file autogen.h.

◆ add

Definition at line 63 of file autogen.h.

◆ sum

Definition at line 75 of file autogen.h.

◆ Tangent

Definition at line 15 of file autogen.h.

◆ zero

Definition at line 51 of file autogen.h.

Function Documentation

◆ autodiff_type_fun()

◆ autodiff_type_fun_pi()

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

◆ id_pullback()

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

Definition at line 32 of file autodiff.cpp.

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

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

◆ normalize_ad()

Ref thorin::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 thorin::World::raw_app(), and thorin::Def::world().

◆ normalize_AD()

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

Definition at line 18 of file normalizers.cpp.

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

◆ normalize_add()

Ref thorin::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 thorin::plug::core::add, thorin::Lit::as(), thorin::Def::projs(), thorin::Idx::size(), and thorin::Def::world().

◆ normalize_sum()

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

Definition at line 90 of file normalizers.cpp.

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

◆ normalize_Tangent()

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

Definition at line 25 of file normalizers.cpp.

References tangent_type_fun().

◆ normalize_zero()

Ref thorin::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 thorin::World::raw_app(), and thorin::Def::world().

◆ op_sum()

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

◆ pullback_type()

const Pi * thorin::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 thorin::Def::world().

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

◆ register_normalizers()

void thorin::plug::autodiff::register_normalizers ( Normalizers normalizers)

Referenced by thorin_get_plugin().

◆ tangent_type_fun()

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

◆ zero_def()

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

◆ zero_pullback()

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

Variable Documentation

◆ Plugin_Id

constexpr plugin_t thorin::plug::autodiff::Plugin_Id = 0x9655014a1c70000
staticconstexpr

Definition at line 10 of file autogen.h.