MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
autogen.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/axm.h>
4#include <mim/plugin.h>
5
6/// @namespace mim::plug::autodiff @ref autodiff
7namespace mim {
8namespace plug::autodiff {
9
10static constexpr plugin_t Plugin_Id = 0x9655014a1c70000;
11
12/// @name %%autodiff.Tangent
13///@{
14enum class Tangent : flags_t {
15};
16
17const Def* normalize_Tangent(const Def*, const Def*, const Def*);
18///@}
19
20/// @name %%autodiff.AD
21///@{
22enum class AD : flags_t {
23};
24
25const Def* normalize_AD(const Def*, const Def*, const Def*);
26///@}
27
28/// @name %%autodiff.ad
29///@{
30enum class ad : flags_t {
31};
32
33const Def* normalize_ad(const Def*, const Def*, const Def*);
34///@}
35
36/// @name %%autodiff.zero
37///@{
38enum class zero : flags_t {
39};
40
41const Def* normalize_zero(const Def*, const Def*, const Def*);
42///@}
43
44/// @name %%autodiff.add
45///@{
46enum class add : flags_t {
47};
48
49const Def* normalize_add(const Def*, const Def*, const Def*);
50///@}
51
52/// @name %%autodiff.sum
53///@{
54enum class sum : flags_t {
55};
56
57const Def* normalize_sum(const Def*, const Def*, const Def*);
58///@}
59
60/// @name %%autodiff.zero_repl
61///@{
62enum class zero_repl : flags_t {
63};
64
65///@}
66
67/// @name %%autodiff.eval
68///@{
69enum class eval : flags_t {
70};
71
72///@}
73
74/// @name %%autodiff.diff
75///@{
76enum class diff : flags_t {
77 core_icmp_xYgLE = 0x9655014a1c70800,
78 core_wrap_add = 0x9655014a1c70801,
79 core_wrap_mul = 0x9655014a1c70802,
80};
81
82///@}
83
85
86#define MIM_autodiff_NORMALIZER_IMPL \
87 void register_normalizers(Normalizers& normalizers) {\
88 normalizers[flags_t(Annex::Base<Tangent>)] = &normalize_Tangent; \
89 normalizers[flags_t(Annex::Base<AD>)] = &normalize_AD; \
90 normalizers[flags_t(Annex::Base<ad>)] = &normalize_ad; \
91 normalizers[flags_t(Annex::Base<zero>)] = &normalize_zero; \
92 normalizers[flags_t(Annex::Base<add>)] = &normalize_add; \
93 normalizers[flags_t(Annex::Base<sum>)] = &normalize_sum; \
94 }
95} // namespace plug::autodiff
96
97#ifndef DOXYGEN // don't include in Doxygen documentation
98
99template<> constexpr flags_t Annex::Base<plug::autodiff::Tangent> = 0x9655014a1c70000;
100template<> constexpr size_t Annex::Num<plug::autodiff::Tangent> = 0;
101template<> constexpr flags_t Annex::Base<plug::autodiff::AD> = 0x9655014a1c70100;
102template<> constexpr size_t Annex::Num<plug::autodiff::AD> = 0;
103template<> constexpr flags_t Annex::Base<plug::autodiff::ad> = 0x9655014a1c70200;
104template<> constexpr size_t Annex::Num<plug::autodiff::ad> = 0;
105template<> constexpr flags_t Annex::Base<plug::autodiff::zero> = 0x9655014a1c70300;
106template<> constexpr size_t Annex::Num<plug::autodiff::zero> = 0;
107template<> constexpr flags_t Annex::Base<plug::autodiff::add> = 0x9655014a1c70400;
108template<> constexpr size_t Annex::Num<plug::autodiff::add> = 0;
109template<> constexpr flags_t Annex::Base<plug::autodiff::sum> = 0x9655014a1c70500;
110template<> constexpr size_t Annex::Num<plug::autodiff::sum> = 0;
111template<> constexpr flags_t Annex::Base<plug::autodiff::zero_repl> = 0x9655014a1c70600;
112template<> constexpr size_t Annex::Num<plug::autodiff::zero_repl> = 0;
113template<> constexpr flags_t Annex::Base<plug::autodiff::eval> = 0x9655014a1c70700;
114template<> constexpr size_t Annex::Num<plug::autodiff::eval> = 0;
115template<> constexpr flags_t Annex::Base<plug::autodiff::diff> = 0x9655014a1c70800;
116template<> constexpr size_t Annex::Num<plug::autodiff::diff> = 3;
117
118template<> struct Axm::IsANode<plug::autodiff::zero_repl> { using type = Axm; };
119template<> struct Axm::IsANode<plug::autodiff::eval> { using type = Axm; };
120template<> struct Axm::IsANode<plug::autodiff::diff> { using type = Axm; };
121
122#endif
123} // namespace mim
124
125#ifndef DOXYGEN // don't include in Doxygen documentation
126
127template<> struct fe::is_bit_enum<mim::plug::autodiff::diff> : std::true_type {};
128
129#endif
Base class for all Defs.
Definition def.h:273
The automatic differentiation Plugin
Definition autodiff.h:7
const Def * normalize_Tangent(const Def *, const Def *, const Def *arg)
const Def * normalize_add(const Def *type, const Def *callee, const Def *arg)
Currently resolved the full addition.
static constexpr plugin_t Plugin_Id
Definition autogen.h:10
const Def * normalize_AD(const Def *, const Def *, const Def *arg)
const Def * normalize_ad(const Def *, const Def *, const Def *)
Currently this normalizer does nothin.
const Def * normalize_sum(const Def *type, const Def *callee, const Def *arg)
const Def * normalize_zero(const Def *, const Def *, const Def *)
Currently this normalizer does nothing.
void register_normalizers(Normalizers &normalizers)
Definition ast.h:16
u64 flags_t
Definition types.h:39
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:27
u64 plugin_t
Definition types.h:40
@ Axm
Definition def.h:122
static constexpr size_t Num
Number of Axm::subtags.
Definition plugin.h:247
static constexpr flags_t Base
Definition plugin.h:248