@@ -19,6 +19,68 @@ pullback_dC!(ΔC, β::Number) = scale!(ΔC, conj(β))
1919@inline EnzymeRules. inactive_type (:: Type{<:TensorKit.GenericTreeTransformer} ) = true
2020@inline EnzymeRules. inactive_type (:: Type{<:TensorKit.VectorSpace} ) = true
2121
22+ function EnzymeRules. augmented_primal (
23+ config:: EnzymeRules.RevConfigWidth{1} ,
24+ :: Const{typeof(subblock)} ,
25+ :: Type{RT} ,
26+ t:: Annotation{<:AbstractTensorMap} ,
27+ f:: Annotation ,
28+ ) where {RT}
29+ ret = EnzymeRules. needs_primal (config) ? subblock (t. val, f. val) : nothing
30+ dret = if ! isa (t, Const) && EnzymeRules. needs_shadow (config)
31+ subblock (t. dval, f. val)
32+ elseif EnzymeRules. needs_shadow (config)
33+ Enzyme. make_zero (ret)
34+ else
35+ nothing
36+ end
37+ return EnzymeRules. AugmentedReturn (ret, dret, dret)
38+ end
39+
40+ function EnzymeRules. reverse (
41+ config:: EnzymeRules.RevConfigWidth{1} ,
42+ :: Const{typeof(subblock)} ,
43+ :: Type{RT} ,
44+ cache,
45+ t:: Annotation{<:AbstractTensorMap} ,
46+ f:: Annotation ,
47+ ) where {RT}
48+ dret = cache
49+ if ! isnothing (dret) && ! isa (t, Const)
50+ subblock (t. dval, f. val) .= dret
51+ end
52+ return (nothing , nothing )
53+ end
54+
55+ function EnzymeRules. forward (
56+ config:: EnzymeRules.FwdConfigWidth{1} ,
57+ :: Const{typeof(subblock)} ,
58+ :: Type{RT} ,
59+ t:: Annotation{<:AbstractTensorMap} ,
60+ f:: Annotation ,
61+ ) where {RT}
62+ ret = EnzymeRules. needs_primal (config) ? subblock (t. val, f. val) : nothing
63+ dret = if ! isa (t, Const) && EnzymeRules. needs_shadow (config)
64+ subblock (t. dval, f. val)
65+ elseif EnzymeRules. needs_shadow (config)
66+ Enzyme. make_zero (ret)
67+ else
68+ nothing
69+ end
70+ if EnzymeRules. needs_primal (config) && EnzymeRules. needs_shadow (config)
71+ return Duplicated (ret, dret)
72+ elseif EnzymeRules. needs_primal (config)
73+ return ret
74+ elseif EnzymeRules. needs_shadow (config)
75+ return dret
76+ else
77+ return nothing
78+ end
79+ end
80+
81+ @inline EnzymeRules. inactive (:: typeof (TensorKit. fsbraid), :: Any ) = nothing
82+ @inline EnzymeRules. inactive (:: typeof (TensorKit. fsbraid), :: Any , :: Any ) = nothing
83+ @inline EnzymeRules. inactive (:: typeof (TensorKit. artin_braid), :: Any , :: Any ) = nothing
2284@inline EnzymeRules. inactive (:: typeof (TensorKit. sectorstructure), :: Any ) = nothing
2385@inline EnzymeRules. inactive (:: typeof (TensorKit. degeneracystructure), :: Any ) = nothing
2486@inline EnzymeRules. inactive (:: typeof (TensorKit. select), s:: HomSpace , i:: Index2Tuple ) = nothing
0 commit comments