Automatic differentiation creates new functions behind the scenes, and thus needs to come up with names for those functions. I'm using a hacky suffix right now to unique these functions, but I wonder what's the proper way to build this into the mangler.
Here's an example. When you differentiate a SIL function @foo
, AD emits the following functions:
- The primal function:
@foo__primal_src_0_wrt_0_1
, meaning "foo's primal function for computing partial derivatives from output0
with respect to parameters0
and1
. - The adjoint function:
@foo__adjoint_src_0_wrt_0_1
, meaning "foo's adjoint function for computing partial derivatives from output0
with respect to parameters0
and1
.
Above are mostly the source index and differentiation parameter indices. There are also things like gradient configurations
-
_s
: seedable -
_p
: preserving result -
_d
: delayed
These hacky suffixes certainly aren't ready for upstreaming AD to the master branch in the future. In practice, they work for most cases, but sometimes interfere with passes like ObjectOutliner, which says
Can't demangle: $S4grad4testy10TensorFlow0C0VySfGAFF__grad_src_0_wrt_0_s_pTv_
Serialization experts, any thoughts on how I should proceed?