Skip to content

Commit 49d92d9

Browse files
committed
boundary gradient functions
1 parent c3a74cd commit 49d92d9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/zygote.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ function Zygote.accum(x::NamedTuple{(:side_lengths,), Tuple{SVector{2, T}}}, y::
8383
RectangularBoundary(x.side_lengths .+ y; check_positive=false)
8484
end
8585

86+
function Zygote.accum(x::NamedTuple{(:side_lengths,), Tuple{SVector{3, T}}}, y::SizedVector{3, T, Vector{T}}) where T
87+
CubicBoundary(x.side_lengths .+ y; check_positive=false)
88+
end
89+
90+
function Zygote.accum(x::NamedTuple{(:side_lengths,), Tuple{SVector{2, T}}}, y::SizedVector{2, T, Vector{T}}) where T
91+
RectangularBoundary(x.side_lengths .+ y; check_positive=false)
92+
end
93+
8694
function Zygote.accum(x::NamedTuple{(:side_lengths,), Tuple{SizedVector{3, T, Vector{T}}}}, y::SVector{3, T}) where T
8795
CubicBoundary(SVector{3, T}(x.side_lengths .+ y); check_positive=false)
8896
end
@@ -99,6 +107,14 @@ function Base.:+(x::NamedTuple{(:side_lengths,), Tuple{SizedVector{2, T, Vector{
99107
RectangularBoundary(SVector{2, T}(x.side_lengths .+ y.side_lengths); check_positive=false)
100108
end
101109

110+
function Base.:+(x::CubicBoundary{T}, y::NamedTuple{(:side_lengths,), Tuple{SVector{3, T}}}) where T
111+
CubicBoundary(SVector{3, T}(x.side_lengths .+ y.side_lengths); check_positive=false)
112+
end
113+
114+
function Base.:+(x::RectangularBoundary{T}, y::NamedTuple{(:side_lengths,), Tuple{SVector{2, T}}}) where T
115+
RectangularBoundary(SVector{2, T}(x.side_lengths .+ y.side_lengths); check_positive=false)
116+
end
117+
102118
function Base.:+(x::SVector{3, T}, y::CubicBoundary{T}) where T
103119
CubicBoundary(x .+ y.side_lengths; check_positive=false)
104120
end

0 commit comments

Comments
 (0)