Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
autogen.h
Go to the documentation of this file.
1#pragma once
2
3#include <thorin/axiom.h>
4#include <thorin/plugin.h>
5
6/// @namespace thorin::plug::autodiff @ref autodiff
7namespace thorin {
8namespace plug::autodiff {
9
10static constexpr plugin_t Plugin_Id = 0x9655014a1c70000;
11
12/// @name %%autodiff.Tangent
13///@{
14#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
16#else
17enum class Tangent : flags_t {
18#endif
19};
20
22///@}
23
24/// @name %%autodiff.AD
25///@{
26#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
27enum AD : flags_t {
28#else
29enum class AD : flags_t {
30#endif
31};
32
34///@}
35
36/// @name %%autodiff.ad
37///@{
38#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
39enum ad : flags_t {
40#else
41enum class ad : flags_t {
42#endif
43};
44
46///@}
47
48/// @name %%autodiff.zero
49///@{
50#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
51enum zero : flags_t {
52#else
53enum class zero : flags_t {
54#endif
55};
56
58///@}
59
60/// @name %%autodiff.add
61///@{
62#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
63enum add : flags_t {
64#else
65enum class add : flags_t {
66#endif
67};
68
70///@}
71
72/// @name %%autodiff.sum
73///@{
74#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
75enum sum : flags_t {
76#else
77enum class sum : flags_t {
78#endif
79};
80
82///@}
83
84/// @name %%autodiff.ad_eval_pass
85///@{
86#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
88#else
89enum class ad_eval_pass : flags_t {
90#endif
91};
92
93///@}
94
95/// @name %%autodiff.ad_zero_pass
96///@{
97#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
99#else
100enum class ad_zero_pass : flags_t {
101#endif
102};
103
104///@}
105
106/// @name %%autodiff.ad_zero_cleanup_pass
107///@{
108#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
110#else
111enum class ad_zero_cleanup_pass : flags_t {
112#endif
113};
114
115///@}
116
117/// @name %%autodiff.ad_ext_cleanup_pass
118///@{
119#ifdef DOXYGEN // see https://github.com/doxygen/doxygen/issues/9668
121#else
122enum class ad_ext_cleanup_pass : flags_t {
123#endif
124};
125
126///@}
127
129
130#define THORIN_autodiff_NORMALIZER_IMPL \
131 void register_normalizers(Normalizers& normalizers) {\
132 normalizers[flags_t(Annex::Base<Tangent>)] = &normalize_Tangent; \
133 normalizers[flags_t(Annex::Base<AD>)] = &normalize_AD; \
134 normalizers[flags_t(Annex::Base<ad>)] = &normalize_ad; \
135 normalizers[flags_t(Annex::Base<zero>)] = &normalize_zero; \
136 normalizers[flags_t(Annex::Base<add>)] = &normalize_add; \
137 normalizers[flags_t(Annex::Base<sum>)] = &normalize_sum; \
138 }
139} // namespace plug::autodiff
140
141#ifndef DOXYGEN // don't include in Doxygen documentation
142template<> constexpr flags_t Annex::Base<plug::autodiff::Tangent> = 0x9655014a1c70000;
143template<> constexpr size_t Annex::Num<plug::autodiff::Tangent> = 0;
144template<> constexpr flags_t Annex::Base<plug::autodiff::AD> = 0x9655014a1c70100;
145template<> constexpr size_t Annex::Num<plug::autodiff::AD> = 0;
146template<> constexpr flags_t Annex::Base<plug::autodiff::ad> = 0x9655014a1c70200;
147template<> constexpr size_t Annex::Num<plug::autodiff::ad> = 0;
148template<> constexpr flags_t Annex::Base<plug::autodiff::zero> = 0x9655014a1c70300;
149template<> constexpr size_t Annex::Num<plug::autodiff::zero> = 0;
150template<> constexpr flags_t Annex::Base<plug::autodiff::add> = 0x9655014a1c70400;
151template<> constexpr size_t Annex::Num<plug::autodiff::add> = 0;
152template<> constexpr flags_t Annex::Base<plug::autodiff::sum> = 0x9655014a1c70500;
153template<> constexpr size_t Annex::Num<plug::autodiff::sum> = 0;
154template<> constexpr flags_t Annex::Base<plug::autodiff::ad_eval_pass> = 0x9655014a1c70600;
155template<> constexpr size_t Annex::Num<plug::autodiff::ad_eval_pass> = 0;
156template<> constexpr flags_t Annex::Base<plug::autodiff::ad_zero_pass> = 0x9655014a1c70700;
157template<> constexpr size_t Annex::Num<plug::autodiff::ad_zero_pass> = 0;
158template<> constexpr flags_t Annex::Base<plug::autodiff::ad_zero_cleanup_pass> = 0x9655014a1c70800;
159template<> constexpr size_t Annex::Num<plug::autodiff::ad_zero_cleanup_pass> = 0;
160template<> constexpr flags_t Annex::Base<plug::autodiff::ad_ext_cleanup_pass> = 0x9655014a1c70900;
161template<> constexpr size_t Annex::Num<plug::autodiff::ad_ext_cleanup_pass> = 0;
162
163template<> struct Axiom::Match<plug::autodiff::ad_eval_pass> { using type = Axiom; };
164template<> struct Axiom::Match<plug::autodiff::ad_zero_pass> { using type = Axiom; };
165template<> struct Axiom::Match<plug::autodiff::ad_zero_cleanup_pass> { using type = Axiom; };
166template<> struct Axiom::Match<plug::autodiff::ad_ext_cleanup_pass> { using type = Axiom; };
167#endif
168} // namespace thorin
Helper class to retrieve Infer::arg if present.
Definition def.h:85
@ Axiom
Definition def.h:39
Ref normalize_AD(Ref type, Ref callee, Ref arg)
Ref normalize_sum(Ref type, Ref callee, Ref arg)
Ref normalize_zero(Ref type, Ref callee, Ref arg)
Currently this normalizer does nothing.
Ref normalize_add(Ref type, Ref callee, Ref arg)
Currently resolved the full addition.
Ref normalize_ad(Ref type, Ref callee, Ref arg)
Currently this normalizer does nothin.
Ref normalize_Tangent(Ref, Ref, Ref arg)
void register_normalizers(Normalizers &normalizers)
static constexpr plugin_t Plugin_Id
Definition autogen.h:10
Definition cfg.h:11
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
u64 plugin_t
Definition types.h:47
u64 flags_t
Definition types.h:46
static constexpr flags_t Base
Definition plugin.h:121